0

This is my method here:

private void trackPrinter(){

    File file = new File("track.txt");
    String absolutePath = file.getAbsolutePath();
    String filePath = absolutePath;

    try {


    FileReader readerT = new FileReader(filePath);
    BufferedReader brT = new BufferedReader(readerT);
    jTextArea2.read(brT, null);
    brT.close();
    jTextArea2.requestFocus();
    } catch(Exception e) { JOptionPane.showMessageDialog(null, e);
    }
}

I've tried many different ways to pass the file in but each time it throws a NullPointerException. if i use jfilechooser the method works fine, except i want the file to open and read on start up.

lsd992
  • 11
  • 2
  • What's the error and possibly because the file doesn't exist? – Andrew Li May 23 '16 at 01:56
  • Please let us know what line the `NullPointerException` is occurring on. (And don't just give us the line number--that doesn't help us. Figure out which Java line it is, and let us know.) – ajb May 23 '16 at 01:56
  • 2
    what is `jTextArea2` ? you should look at that – sonique May 23 '16 at 01:56

0 Answers0