I'm working on a Java project to Add each Integer to the one in the next line until there's no lines to read in the file. So to be able to add it I have to use Integer.parseInt(...) to the line then add it. P.S : the for loop will just skip two lines which contain the header of the file. And all the string are refering to numbers which Integer.parseInt() accepts.
Here's the full exception error :
Exception in thread "main" java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at prog.Result(prog.java:93)
at prog.main(prog.java:56)
The code resulting in the exception is :
public static void Result() throws IOException
{
FileReader fileReader = new FileReader(dir+"/"+log_file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
int i;
for (i=0;i<=2;++i)
{
bufferedReader.readLine();
}
int result =0;
while (bufferedReader.readLine() != null)
{
result += Integer.parseInt(bufferedReader.readLine());
}
System.out.println("The Result Is : " + result);
}