I'm new to Java programming. I use java to write simple macros for my simulation tool. In the following part of the code I want to find a minimum and a maximum value in a csv file which is "whitespace" seperated.
Now, I have the problem that I get the java.lang.NullPointerException message on my output- window. Than it says that the macro playing is done.
I have some marker in the code and the output ends on this position.
Does anybody have the clue why this not work?
public void VelMinandMax (String Velocity_Data) {
velMagMax = 0.0 ;
velMagMin = 100.0 ;
FileReader fr1 = null ;
BufferedReader br1 = null ;
Scanner sc1 = null ;
try {
fr1 = new FileReader(Velocity_Data);
br1 = new BufferedReader(fr1);
sc1 = new Scanner(br1);
while (sc1.hasNextLine()) {
sc1.nextLine();
if (sc1.hasNextDouble()) {
double velMag = sc1.nextDouble();
double coordX = sc1.nextDouble();
double coordY = sc1.nextDouble();
double coordZ = sc1.nextDouble();
if (velMag>velMagMax)
{
velMagMax = velMag ;
}
if (velMag<velMagMin)
{
velMagMin = velMag ;
}
}
}
}
catch (FileNotFoundException e) {
System.out.println ("Error : File Not Found") ;
}
finally {
sc1.close() ;
try {
br1.close() ;
fr1.close() ;
}
catch (IOException e2) {
System.out.println ("IOException");
}
}
}
Edit Output:
public execute MethodVol CalcVelRef VelMinandMax java.lang.NullPointerException