Reading standard input

i don't know why it's not working when i use BufferedReading and System.in to read input from the keyboard.
//taking a1, a2 from the standard input
BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please enter a1,a2 separated by space...");
System.out.flush();
try {
line = bin.readLine();
System.out.println("Your input line was "+ line);
} catch (IOException e) {e.printStackTrace();}
when i run it the output goes like:
Please enter a1,a2 separated by space...
Your input line was
Then the program just abruptly ended.
i know this might be a dumb question. but i really don't understand why Java doesn't have an easier way to take input like in C.
Please help! thanks a bunch.

hey, i was not prompted for any input! that's why i am puzzled. i am used to the simple syntax in C:
printf("enter blah blah...");
scanf("%s",name)
am i missing the line that's actually prompting the user for input?
thanks!

Similar Messages

  • BR0255W Cannot read from standard input during a dbverify

    Hello,
    I am using:
    BRBACKUP 7.20 (13)
    SunOS 5.10 Generic_144488-06 sun4u
    701 SAPSR3
    Oracle 11.2.0,.2
    brbackup -w only_dbv -t online -c -u / -e 16
    It generally runs ok, but today I got:
    BR0280I BRBACKUP time stamp: 2011-04-20 11.20.47
    BR0063I 5 of 11 files processed - 14900.039 of 73640.086 MB done
    BR0204I Percentage done: 20.23%, estimated end time: 12:45
    BR0001I **********________________________________________
    BR0280I BRBACKUP time stamp: 2011-04-20 11.21.44
    BR0281W BRBACKUP interrupted by signal 2
    BR0269W Wait situation interrupted - probably cannot continue
    BR0280I BRBACKUP time stamp: 2011-04-20 11.21.44
    BR0256I Enter 'c[ont]' to continue, 's[top]' to cancel BRBACKUP:
    BR0280I BRBACKUP time stamp: 2011-04-20 11.21.45
    BR0251W Function gets() failed at location BrConfEnter-1
    BR0253W errno 5: I/O error
    BR0255W Cannot read from standard input
    BR0280I BRBACKUP time stamp: 2011-04-20 11.21.45
    BR0261E BRBACKUP cancelled by signal 2
    BR0056I End of database backup: befrzrsn.dbv 2011-04-20 11.21.46
    BR0280I BRBACKUP time stamp: 2011-04-20 11.21.49
    BR0054I BRBACKUP terminated with errors
    1. Would you know what yould cause this Cannot read from standard input?
    2. Is there a maximum number of process that can/should be passed to -e option?
    Thanks in advance for your answer.

    Hello Benoît,
    if I understood correctly, your brbackup was not started interactively, but in background, by crontab or DB13 or something like that.
    As you perhaps know, signal 2 usually means that the process was interrupted by a ctrl-C from keyboard. This should not happen for a background process.
    It could be that someone played around with kill command.
    I rather suspect some resource bottleneck.
    Could you please check Unix kernel parameters (or whatever their equivalent in SunOS is called - I am not familiar with it).
    Or any suspicious entries in Unix log files?
    regards

  • How to Read from Standard Input?

    Hi,
    I am new to Java. Been reading the tutorial, but still unable to find How to read from standard Input.
    Can anyone help? Thanks.
    Here is my simple & error code:
    public class test
    public static void main(String[] args)
    char filename[];
    int i=0;
    System.out.print("Type in a filename to read: ");
    while ( System.in(filename) != -1 )
    i++;
    System.out.print(filename);
    RP

    import java.io.*;
    public class forum{
         public static void main(String args[]) throws IOException
    InputStreamReader is = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(is);
    String input = "";
    do
    try
    System.out.println("Enter command: ");
    input = br.readLine();
    catch ( IOException io ) {}
    } while (!input.equals("exit"));
    [code\]
    package to import is java.io.*;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • BRGUI: Connect WindowsXP to AIX: BR0255E Cannot read from standard input

    Hi,
    I configure brgui.properties and seam everything ok:
    brgui.remote-0=D11 (rsh aixd11 -l orad11)
    It connect to server, but in the footer of 2nd BRGUI screen (after login screen) it appears "Error: Cannot read from standard input" in red.
    And some seconds later the application closes.
    I see the log and it has the following:
    BR0651I BRTOOLS 7.00 (16)
    BR0280I BRTOOLS time stamp: 2008-04-15 16.30.10
    BR0656I Choice menu 1 - please make a selection
    BR*Tools main menu
    1 = Instance management
    2 - Space management
    3 - Segment management
    4 - Backup and database copy
    5 - Restore and recovery
    6 - Check and verification
    7 - Database statistics
    8 - Additional functions
    9 - Exit program
    Standard keys: c - cont, b - back, s - stop, r - refr, h - help
    BR0662I Enter your choice:
    BR0280I BRTOOLS time stamp: 2008-04-15 16.30.10
    BR0255E Cannot read from standard input
    BR0280I BRTOOLS time stamp: 2008-04-15 16.30.10
    BR0654I BRTOOLS terminated with errors
    Can anybody help? Maybe is it related with AIX files authorizations?
    Thanks a lot!
    Rui

    Hi Rui,
    Please take note on the following important points.
    When you use the remote option, ensure that the environment on the
    remote host is fully configured to use the BR*Tools, and that the remoteuser has the relevant database rights. You should also ensure that the
    relevant environment files are actually called up during the remote
    access.
    and
    In some cases, BrGui does not work with the Remote Shell rsh from from
    Microsoft Windows XP Service Pack 2 or Microsoft Windows Server 2003
    Service Pack 1. See Microsoft Support Article ID 896336. Microsoft
    offers a hotfix for this purpose. As a workaround, use the rsh from the
    previous Service Pack. This is located in the uninstall directory after
    the Service Pack has been installed. You can also enter the complete
    path in the relevant remote call.
    Hope the above information helps.

  • Search help unavailable in Read-only input field since EHP4

    Dear Experts!
    I have a problem with a Portal page since the deploy of the EHP4. The page has standard input fields with Search Helps. I needed to have the input field non-modifiable so the user would have to use the search help to get the proper information.
    Prior to the EHP4 installation, I set the input field to Read Only in the WebDynpro explorer, this disabled the editing while permitting the user to use the Search Help.
    Since the installation, the search help is no longer visible or accessible on a Read Only standard inputfield.
    Do you know if there is a way to allow the search help on a read only field?
    Thanks so much for your answer,
    Brian Foster.

    >Since the installation, the search help is no longer visible or accessible on a Read Only standard inputfield.
    This was a conscious design decision on SAP's part that disabled or read-only fields should no longer fire value help.  I am aware that this situation was used in the past as you describe.  It is even still used in SE80 for the Web Dynpro ABAP wizards. However usability studies showed that this often confused end users and therefore it is no longer allowed.  The field must be input enabled to fire the attached serach help.

  • Java debugging - problems with standard input

    Hi
    I hope somebody can help me with this problem.
    I'm developing a Java app that reads from the standard input. I use System.in.read() to do that. When I debug it, I use the Standard I/O window instead of the Run Log window to pass in values, but nothing happens (i.e. the line following the read() is never reached). I also tried to run the app and then attach the debugger to use the Run Log window as standard input, with the same result. If I add a breakpoint before the call to read(), the debugger pauses the execution, so I suppose the breakpoints are OK.
    In the executable Info window, Debugging tab, I use the pseudo terminal with the Java debugger.
    So my question is: how can I enter values from the standard input in debugging mode?

    I believe that you are seeing these problems because we have found the
    current versions of RMI found in the JDK to be inherently unscalable -- we
    do not listen for them. As you noticed, we recommend that you use our
    packages for now, and then do the simple change that you found if you decide
    that you do not like WLS. (If you do decide that you do not like us, please
    definitely let us know why you chose the way you did!)
    Thanks,
    Michael
    Michael Girdley
    Product Manager, WebLogic Server & Express
    BEA Systems Inc
    "Tim Dawson" <[email protected]> wrote in message
    news:397b8cc2$[email protected]..
    We're developing a J2EE application on NT using WLS 5.1, SP3, but we don't
    want to be tied to any particular J2EE server, so we're making sure that
    none of our code is weblogic specific.
    In keeping with this philosophy, I created an RMI service that used the
    standard java.rmi.* imports instead of weblogic.rmi.* and used thestandard
    RMIC compiler rather than the weblogic.rmic compiler.
    Unfortunately, I couldn't get the system to work. I kept getting
    "java.rmi.MarshalException: Error marshaling transport header; nested
    exception is: java.io.EOFException" whenever I'd call Naming.lookup().
    Of course, when I did the search & replace with java.rmi.* with
    weblogic.rmi.*, and switched from the standard rmic to weblogic.rmic,
    everything started working just fine. This is the ONLY change I made!
    Has anyone else run into similar problems?
    Tim Dawson
    Sr. Software Architect
    is.com

  • Unix standard input/output

    My issue is: how can I read from Unix standard input in Java when it is piped from another Unix program. For instance:
    `cat foo.txt | java MyProgram ?????' . Should I follow this way or should I do in another way?
    Thanks
    puccio.

    not quite what you are looking for, but im thinking this will help http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    link supplied by NtQuest (many thanks)
    mebby we should get a handy links page, i know of several that i keep posting and never remember to keep, so i gotta keep looking it up

  • Can send characters to the standard input while DOS Command is under execution

    Can Labview send characters to the standard input while DOS Command is under running with System Exec.vi?

    iftu wrote:
    Found following VI's in ogpipe.llb under the ZIP file. Didn't find PING Example.vi
    OGPIPE Write To Pipe__ogtk.vi
    OGPIPE RefNum__ogtk.ctl
    OGPIPE Read From Pipe__ogtk.vi
    OGPIPE Open System Command__ogtk.vi
    OGPIPE Open Pipe__ogtk.vi
    OGPIPE Close Pipe__ogtk.vi
    OGPIPE - VI TREE__ogtk.vi
    PING Example is not in that archive. This is only the actual PIPE function library. What you want to do is using "OGPIPE Open System Command" to create the pipe handles for stdin and stdout and optinally stderr. Then use "OGPIPE Write To Pipe" to write to stdin and "OGPIPE Read From Pipe" to read from stdout and optionally stderr. When finished close each opened pipe handle with "OGPIPE Close Pipe".
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Standard input

    This program will take file names on the command line and read the contents of each file in line by line. If a "-" (i.e., a hyphen) is specified for a file name, the program should use standard input for that file rather than opening a file called "-". For example,
    sortit file1.txt - file3.txt
    will sort all of the lines in file1.txt, standard input, and file3.txt.
    could anyone elaborate on the standard input part.

    System.in

  • I'm having trouble using standard input inside JDB

    Hello Java(R) community
    The problem is:
    I cannot read a stream of characters from the keyboard inside JDB. Just to set context I'm using:
    jdk 1.3.1_01 with jdb version 99/06/11 under RedHat(R) Linux(R) 7.1
    I've written the following code:
    1:import java.io.*;
    2:
    3:public class Test {
    4:
    5: Reader reader = new InputStreamReader(System.in);
    6: char[] buffer = new char[256];
    7:
    8: public void myRead() {
    9:
    10: System.out.print("Insert some text: ");
    11: try {
    12: reader.read(buffer);
    13: }
    14: catch (IOException e) {
    15: System.out.println(e.getMessage());
    16: }
    17: System.out.println("You've inserted the following text: " + new String(buffer));
    18: }
    19:
    20: public static void main(String[] args) {
    21:
    22: Test ref = new Test();
    23: ref.myRead();
    24: }
    25:}
    The above is compiled with javac -g Test.java
    At the shell you run ' java Test ' and it just echoes the input you give to it
    Inside jdb you set a breakpoint with ' stop in Test.myRead()'. When there, it stops at line 10; you invoke the 'next' command and it just don't print the message (just becuse it's not a println it just don't flush I suppose); after that the next line to execute is 12; so you invoke 'next' again and the real problem happens! Nothing can be read from the standard input. If you try to run the 'list' command jdb says "Current thread isn't suspended".
    Does anyone knows what's going on?
    Thanks in advance for a reply.

    If you use the launching connector to start the debugee,
    (this is the default used when you start jdb)
    then jdb cannot tell the difference between jdb commands
    that you are typing, and other text you want sent to the
    debugee program. You will have the same problem with
    output going the other way. The debugee program output
    will be mixed in with any jdb output that comes along.
    This is because the controlling window has only one stdin,
    stdout, stderr that both processes (as well as anything else
    you are running in that window) are forced to share.
    You need to separate the debugger and debugee, as follows:
    1) Start the debugee program (HelloWorld in this example)
    in one command window:
    % java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=4571 HelloWorld
    2) In another window, attach your debugger (jdb in this example)
    to the debugee via a socket:
    % jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=4571
    You may also use the shared memory transport if you are
    on a win32 platform, as follows:
    1) In one command window:
    % java -Xdebug -Xrunjdwp:transport=dt_shmem,server=y,address=mine HelloWorld
    2) In a second command window (again using jdb as an example):
    % jdb -connect com.sun.jdi.SharedMemoryAttach:name=mine
    For more information, refer to "Connection and Invocation Details"
    at this URL:
    http://java.sun.com/j2se/1.4/docs/guide/jpda/conninv.html

  • Set up standard  input in solaris to avoid 256 characters limit.

    I do hava a Console command line application in java, the application run in Solaris. I run the program in a ksh script and the maxumin line size i can read is 256 characters. How can i set up the standard input to avoid this limitation. I need no limit in the input command line as can have command longer that 5000 characters.
    How to reproduce the scenario.
    public static void main(String[] args)
    System.in.read()
    Is there any way i can set up or initialize the standard input to avoid this limitation?
    Thanks in advance.

    This is a limitation of the terminal driver, so even if the shell can accept more characters, the terminal in front of the shell will stick to the limit defined by MAX_CANON. There are two ways to get around this problem:
    1. Put the terminal into raw mode: "stty raw -echo"
    or
    2. Introduce explicit backslash-newline sequences into the input stream. The terminal will trigger on the newline, but the backslash will tell the shell to keep looking for the logical end of the input.

  • Dialog programming: making standard input field sensitive to double-click

    Hello,
    I'd like make standard input field sensitive to double-click. I know that I should register double-click event to input field class and write handler. But I can't find out from what class I should derive. What is class of standard input field? Can I derive from that class? Or is there another way to accomplish my requirements?
    Best regards,
    Josef Motl

    I agree with Kinshuk,  Not sure why you need this functionality.   Please implement this sample program do F4 help on the BURKS field and select a company code.  Notice that is populates all the rest of the fields.  Is this the functionality that you require?
    report zrich_0002 .
    parameters: p_bukrs type t001-bukrs,
                p_butxt type t001-butxt,
                p_ort01 type t001-ort01,
                p_land1 type t001-land1.
    data: dynfields type table of dynpread with header line.
    data: return type table of ddshretval with header line.
    at selection-screen on value-request for p_bukrs.
      call function 'F4IF_FIELD_VALUE_REQUEST'
           exporting
                tabname           = 'T001'
                fieldname         = 'BUKRS'
                dynpprog          = sy-cprog
                dynpnr            = sy-dynnr
                dynprofield       = 'P_BUKRS'
           tables
                return_tab        = return
           exceptions
                field_not_found   = 1
                no_help_for_field = 2
                inconsistent_help = 3
                no_values_found   = 4
                others            = 5.
      read table return with key fieldname = 'P_BUKRS'.
    * Add it back to the dynpro.
      dynfields-fieldname = return-retfield.
      dynfields-fieldvalue =  return-fieldval.
      append dynfields.
    * Get the company code from db and add to dynpro
      data: xt001 type t001.
      clear xt001.
      select single * into xt001
             from t001
            where bukrs = return-fieldval.
      dynfields-fieldname = 'P_BUTXT'.
      dynfields-fieldvalue = xt001-butxt.
      append dynfields.
      dynfields-fieldname = 'P_ORT01'.
      dynfields-fieldvalue = xt001-ort01.
      append dynfields.
      dynfields-fieldname = 'P_LAND1'.
      dynfields-fieldvalue = xt001-land1.
      append dynfields.
    * Update the dynpro values.
      call function 'DYNP_VALUES_UPDATE'
           exporting
                dyname     = sy-cprog
                dynumb     = sy-dynnr
           tables
                dynpfields = dynfields
           exceptions
                others     = 8.
    start-of-selection.
    Regards,
    Rich Heilman

  • Read keyboard input as binary

    how can i read keyboard input as binary

    7biscuits wrote:
    I want to be able to get keyboard input as binary as the key is being pressed, without having to press enter,That requirement should have been posted in your original question!
    7biscuits wrote:
    This is required to enable my program respond to (ctrl , alt , shift , F1 , F2 etc) key's.
    Does anyone know how to do it?Reading keyboard input without pressing return on the standard shell (command prompt), this is not possible with Java.

  • Redirect standard input from file to terminal

    Is there any way to redirect standard input from file to terminal within the same program? That is, get data from a file then redirect standard input to make it interactive with the terminal?

    BIJ001 wrote:
    No, the stdin, stderr, stdout, and working directory are environmental variables that are set
    when your process is launched, and they cannot be changed from within your java application.Can't they?
    //java.lang.System
    public static void setIn(InputStream in)
    //   Reassigns the "standard" input stream.
    public static void setOut(PrintStream out)
    //  Reassigns the "standard" output stream.
    public static void setErr(PrintStream err)
    //  Reassigns the "standard" error output stream.
    Since:
    JDK1.1
    Duh, you're right. I researched this looking for a way to change the working directory and found that you could not change that after launch - for some reason I remembered it wrong as being the stderr, stdin, and stdout in addition.

  • Faster tokenizing of standard input?

    Greetings,
    I seek the fastest possible means of reading ints from standard input. The only two delimiters are space and new line. Otherwise, I am certain that all input will be ints, however, some of them are multi digit (ie. 1 vs 101). Currently, I am using a bufferedReader and stringTokenizer. Is there a faster way to get the job done?
    Thanks,
    -chris

    final class MyBufferedReader {
         private InputStream in;
         public MyBufferedReader (InputStream in) {
              this.in = in;}
         public String readLine () throws IOException {
              final StringBuffer sb = new StringBuffer(255);
              int i = 0;
              while (((i = in.read()) != '\n') && (i != -1))
                   if (i != '\r')
                        sb.append((char) i);
              if (i == -1)
                   return null;
              return sb.toString();}
    final class Main {
         public static void main (String[] args) {
              try {
                   MyBufferedReader in = new MyBufferedReader(System.in);
                   String s;
                   while ((s = in.readLine()) != null) {
                        StringTokenizer st = new StringTokenizer(s);
                        int i = Integer.parseInt(st.nextToken());

Maybe you are looking for

  • MacBook Pro (early 2008) with Dell monitor

    I'm looking into buying an additional monitor for next year at college. I'm looking at the Dell U2211H, because its the only one that has the pivot feature that I need for work, as well as has a TV tuner built in. Does anyone know anything about how

  • Custom purchase order text

    Hi,    I need to create new custom purchase order text to display in ME23N and to capture some data. I have created new text id and configured for the required PO document types. But I still don't see the new custom text appears in ME23N. As far as I

  • [SOLVED] bash help: rsync only if device mounted

    Hi, First bash-script here - the tldp.org-guide has gotten me somewhere already, but the final condition 'if rsync...' seems to fail and I don't know why. The script checks if the location to backup the files to is a mountpoint. If not, the script sh

  • Including a web page in my jsf

    Hi, I have a tabbed panel (I'm using myfaces' tomahawk) and I want to include in one tab the content of another web page. Is it possible ? Thank you.

  • Problems refreshing page with AJAX

    Hello, I have never used AJAX but today I decided to try it to improve my current implementation of a "processing" page that I use to display a waiting message and to check every 5 seconds if a response is available. If it is, the user is redirected