Hello all,
I need some help.
When the text file is empty i get the
NullPointerException Error
error. If there is data on the text i do not get the error. What am i doing wrong
- void file_open () {
- String line = "test";
BufferedReader node_reader;
node_reader = createReader("nodedata.txt"); - while (line !=null ) {
- try {
- line = node_reader.readLine();
- if ( line != null ) {
String[] pieces = split(line, TAB);
int a = int(pieces[0]);
int b = int(pieces[1]);
int c = int(pieces[2]);
int d = int(pieces[3]);
int e = int(pieces[4]);
listofNodes.add(new Node(a, b, e)); //
}
} catch (IOException e) {
e.printStackTrace();
line = null;
}
}
}
1