Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Null Point Exception (https://www.askmehelpdesk.com/showthread.php?t=793434)

  • Jun 3, 2014, 02:38 AM
    bestmaster99
    Null Point Exception
    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

  • All times are GMT -7. The time now is 06:39 AM.