java - Null Pointer Exception at EOF -


So I'm currently getting a blank pointer on the last line of this method. Using I have read the others with this issue, but whenever nothing has been left, still should stop the file (= drawing = myReader.readline ())! = Null It does not look like that I can stop catching one NPE instead. I can not understand that this is it. Any advice will be appreciated! I currently support band-assistance using another hold (NullPointerException) statement, but I do not think this is a sufficient solution.

  BufferedReader myReader; {FileInputStream fileInstream = Try New FileInputStream (fileLocation); InputStreamReader File InputStreamReader = New InputStreamReader (file instream, "UTF-16"); MyReader = New BufferedReader (fileInputStreamReader); String line = ""; // read the next line until there is no left (linein = myReader.readLine ())! = Stuff {} stuff with line} system.out.printline ("done"); // file connection closed now That is read.In fileIn.close (); myReader.close ();} hold (exception e) {System.out.println ("Error:" + e.getMessage ()); e.printStackTrace ();  

}

Faucet pointer should never be caught It should be decided that you do not want to campaign in the rest of your code.

Please note that you are closing your file. Finally add the block and close the resources to those files. If an exception is caught in this way, then you will still close your file.


Comments