Results 1 to 6 of 6
  1. #1
    Feng is offline Member
    Join Date
    Nov 2007
    Posts
    13
    Rep Power
    0

    Default JFileChooser/Scanner/openFileReader

    i want to make a dialog box to import a file and then use the buffered reader to use it. should i use (before the BufferedReader) the JFileChooser, the Scanner or the openFileReader? i tried to use all of them but i always got problems that i cant solve. :o

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    If you are using a gui a JFileChooser is an easy way to get a reference to a user–selected file. If using a console application you can use a JOptionPane to receive user input and pass the file path off to your BufferedReader.

  3. #3
    staykovmarin is offline Senior Member
    Join Date
    Nov 2007
    Location
    Newport, WA
    Posts
    141
    Rep Power
    0

    Default

    Java Code:
    BufferedReader br = null;
    The reader is null. A NullPointerException is thrown when you attempt to access something that is null.
    Java Code:
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

  4. #4
    Feng is offline Member
    Join Date
    Nov 2007
    Posts
    13
    Rep Power
    0

    Default

    i had to initialize it thats why I typed null.
    i want to use the JOptionPane.
    anyway thanx for your reply. ;)

  5. #5
    chester is offline Member
    Join Date
    Nov 2007
    Posts
    1
    Rep Power
    0

    Default hallo

    Hi guy, I'm new in java. I hope this forum will make every body know java.:D :rolleyes:

  6. #6
    Feng is offline Member
    Join Date
    Nov 2007
    Posts
    13
    Rep Power
    0

    Default

    Quote Originally Posted by chester View Post
    Hi guy, I'm new in java. I hope this forum will make every body know java.:D :rolleyes:
    This forum is for introductions http://www.java-forums.org/introductions/

Similar Threads

  1. JFileChooser example (selecting a directory)
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 02-03-2009, 01:25 PM
  2. Localize JFileChooser
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-14-2008, 11:54 AM
  3. JFileChooser remember the location
    By Mr tuition in forum AWT / Swing
    Replies: 3
    Last Post: 12-08-2007, 05:17 PM
  4. how to use JFileChooser
    By tommy in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 08:49 PM
  5. help with IP scanner
    By tommy in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 08:00 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
  •