Results 1 to 2 of 2
  1. #1
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    364
    Rep Power
    5

    Default Multiple BufferedReaders?

    I am trying to create a test for my application, and I basically want to have the following output:

    Enter the file location:
    *User enters the file location, next thing printed is:

    Instructions: *wait for response*

    I have

    Java Code:
    System.out.print("Enter your file Location, starting at the C: level: ");
    
          //  open up standard input
          BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
          String fileLoc = null;
    
          //  read the username from the command-line; need to use try/catch with the
          //  readLine() method
          try {
             fileLoc = br.readLine();
             System.out.println("File loaded succesfully");
             br.close();
    
          } catch (IOException ioe) {
             System.out.println("IO error trying to read your file location");
             System.exit(1);
          }
    How would I create another output asking for data? Would I create another BufferedReader?

  2. #2
    Shoss's Avatar
    Shoss is offline Member
    Join Date
    Feb 2011
    Posts
    94
    Rep Power
    0

    Default

    I wouldn't use BufferedReader to do this, it would be best to use Scanner. It is much easier to get user's input using Scanner and requires less code.

Similar Threads

  1. Multiple JFrames
    By frguy in forum Advanced Java
    Replies: 11
    Last Post: 01-08-2011, 11:36 AM
  2. Running multiple threads on multiple CPU cores?
    By Dosta in forum Threads and Synchronization
    Replies: 2
    Last Post: 09-19-2010, 04:48 PM
  3. Multiple SwingWorkers
    By Arne in forum Threads and Synchronization
    Replies: 12
    Last Post: 08-26-2010, 03:54 AM
  4. Use multiple forms
    By coco in forum Java Applets
    Replies: 2
    Last Post: 06-14-2010, 06:14 AM
  5. Multiple Questions
    By Kaito in forum New To Java
    Replies: 4
    Last Post: 10-07-2009, 05:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •