Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2014
    Posts
    1
    Rep Power
    0

    Default Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

    File file = new File("lrt.txt");


    public ArrayList<Station> getAll() throws FileNotFoundException {
    ArrayList<Station> station = new ArrayList<>();
    Scanner input = new Scanner(file);
    try {
    while (input.hasNextLine()) {
    String id = input.nextLine();
    String name = input.nextLine();
    Station temp = new Station(id, name);
    station.add(temp);

    }
    } catch (Exception ex) {
    JOptionPane.showMessageDialog(null, ex);
    }
    Set newSet = new LinkedHashSet(station);
    station.clear();
    station.addAll(newSet);
    return station;
    }




    I dont know what wrong in the code >.< It cannot found the File lrt.txt
    Last edited by asdasdasdasdasd; 03-01-2014 at 10:02 AM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,560
    Blog Entries
    7
    Rep Power
    21

    Default Re: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

    The full error message would've told you where things went wrong but you have hidden it by just displaying a dialog with the simple message of the exception. Change that line in your catch block to 'ex.printStackTrace()' and see what the stack trace has to say ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 1
    Last Post: 12-13-2010, 03:19 PM
  2. Replies: 6
    Last Post: 06-06-2010, 09:02 PM
  3. Replies: 3
    Last Post: 04-30-2010, 07:44 PM
  4. Replies: 5
    Last Post: 08-26-2009, 11:37 AM
  5. Replies: 6
    Last Post: 08-03-2009, 08:58 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
  •