If there is something like this in my code:
String line = r.readLine();
How can I avoid a crash if the next line is the end of the file? (i.e. null)
I need to read the next line because there might be something I need to deal with, but if the code doesnβt just work.
If there is something there, everything is in order, but I can not guarantee that there will be something.
So, if I do something like: (pseudo-code):
if (r.readLine is null) //End code else {check line again and excecute code depending on what the next line is}
The problem with something like this is that when I check the line for zero, it already moves to the next line, so how can I check it again?
I have not developed a way to do this - any suggestions would be a big help.
java file-io readline bufferedreader
Zippy
source share