This is the code I working on. It's inside a method and the idea is for it to open a file and check the contents, or the lack of, and report back.
However I'm getting a NullPointerException
on the line that I pointed to below.
I have no idea how to fix this. I tried debugging which shows that at the time the line is run the 1st element of the String[]
contains text, so that's not a problem.
int i = 0;
int numChar=1, numLines;
String[] line = new String[1000];
try {
BufferedReader in = new BufferedReader(new FileReader(file));
try {
while(numChar > 0) {
//String[] line = new String[1000];
line[i] = in.readLine();
PROBLEM--> numChar = line[1].length();
i++;
}
} catch (EOFException ex) {
JOptionPane.showMessageDialog( null, "Error" );
//break;
}
}
catch(IOException e) {
JOptionPane.showMessageDialog( null, "Missing file or no data to read." );
System.out.println("IO Error - Missing file");
}