bestmaster99
Jun 3, 2014, 02:38 AM
I have problem trying to figure what is wrong with the null point exception. My codes seems to be looking logically fine. As least to me? I am trying to read the content of a text document line by line.
Here's my code:
public void readFile() throws IOException {
BufferedReader in = new BufferedReader(new FileReader("C:/Users/Admin/Dropbox/JiaWei/Advance Java Programming/Practical/studentData.txt"));
while (in.readLine() != null) {
String[] studentData = in.readLine().split(",");
students.add(new Student(studentData[0], Double.parseDouble(studentData[1]), Integer.parseInt(studentData[2])));
}
}
Here is the content of the text file:
A,3.6,100
B,3.6,50
C,3.9,10
D,3.2,80
E,2.9,100
Here's my code:
public void readFile() throws IOException {
BufferedReader in = new BufferedReader(new FileReader("C:/Users/Admin/Dropbox/JiaWei/Advance Java Programming/Practical/studentData.txt"));
while (in.readLine() != null) {
String[] studentData = in.readLine().split(",");
students.add(new Student(studentData[0], Double.parseDouble(studentData[1]), Integer.parseInt(studentData[2])));
}
}
Here is the content of the text file:
A,3.6,100
B,3.6,50
C,3.9,10
D,3.2,80
E,2.9,100