Edit SOLVED: I am being stupid. The input strings were longer than I thought (they were corrupted) in one case so some US data went into the European test and caused the exception when two doubles were concatenated together with a "." creating a string with three decimal points. Changed 7 to 8 and the original code is just fine.
Sorry to all who put time in on this issue.
Edited to add all code at end
I have a csv file that has european decimal values saved for example 12,345 I parse the data into a string and my code throws an exception. I have narrowed it down to one line
Here are the variables
String[] mark = line.split(",");
double wLat = 0;
This line won't work
wLat = Double.parseDouble(mark[3] + "." + mark[4]);
This line (for non eurpoean data) works
wLat = Double.parseDouble(mark[3]);
I am probably doing something stupid but this is difficult to Google and searching sa didn't help. I tried a string builder and append but parseDouble didn't work with a string builder. I would appreciate help on this.
Allen
Edit:
// Read old marks
try {
// read all the old mark settings so we end up with the last ones
// this will restore settings on a restart
BufferedReader br;
br = new BufferedReader(new FileReader(baseDir + "/StartLine/Waypoint_log.csv"));
String line = null;
while ((line = br.readLine()) != null) {
String[] mark = line.split(",");
double wLat = 0;
double wLong = 0;
if (mark.length > 7){ // europe
//wLat = Double.parseDouble(mark[3] + "." + mark[4]);
//wLong = Double.parseDouble(mark[5] + "." + mark[6]);
}
else{ // normal case
wLat = Double.parseDouble(mark[3]);
wLong = Double.parseDouble(mark[4]);
}
int index = Integer.valueOf(mark[0]);
if (wLat >= -90 && wLat <= 90 && wLong >= -180 && wLong <= 180){
StartLine2.waypointNameArray[index] = mark[1];
StartLine2.waypointLat[index] = wLat;
StartLine2.waypointLong[index] = wLong;
StartLine2.waypointSet[index]=1;
index++;
}
}
br.close();
}
catch (Exception e) {
Toast toast=Toast.makeText(this, "No Marks Set",Toast.LENGTH_SHORT);
toast.show();
}