I have small code to read datas from "dat" type of file. It's read fine just when last line is done it's kick-off with error message
Exception in thread "main" java.lang.NullPointerException at CW2.main<CW2.java:26>
import java.io.*;
import java.util.*;
class CW2
{
public static void main( String[] args)
{
try
{
BufferedReader in = new BufferedReader( new FileReader("staff2005.dat"));
String whole;
while(true)
{
try
{
whole = in.readLine();
}
catch (EOFException eof)
{
System.out.println("End of File");
break;
}
System.out.println( whole.trim());
}
in.close();
}
catch (IOException e)
{
System.out.println ( "IO Exception =: " + e );
}
}
}
Just learning, please don't shot me :o . Think there is a problem with my definition of try & catch. Highligted line 26 for you.
Can you please advice on this matter??