I'm parsing a doc and I get the following error:
Exception in thread "main" java.lang.NumberFormatException: For input string: "null"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1222)
at java.lang.Float.valueOf(Float.java:388)
at CentroidGenerator$Centroid.averageLat(CentroidGenerator.java:403)
at CentroidGenerator.getCentroids(CentroidGenerator.java:30)
at CentroidGenerator.main(CentroidGenerator.java:139)
This is the part of code throwing the exception:
if (latitude!=null) {
//if (!latitude.equals("null")) {
String[] latValues = latitude.split(" ");
float sum = 0;
for (int i = 0; i < latValues.length; i++) {
sum = sum + Float.valueOf(latValues[i].trim()).floatValue();
}
latitude = Float.toString(sum / (float) latValues.length);
//}
}
As you can see I've tried to check for "null" strings but even uncommenting the second if statement I get the same error.
thanks