The reason I ask is because I have 2 exact same bits of code in an android app and in a java program doing the same thing (collecting tidal data):
String[] string4 = tide4.replaceAll("[LmH]", "").split(" ");
Time4 = string4[0];
String height4 = string4[1].replaceAll("\\s", "");
System.out.println("HEIGHT4 = " + "'" + height4 + "'" );
//Convert the Meters into feet for tide heights
double heightM4 = Double.parseDouble(height4); //FAILS ON THIS LINE IN **JAVA** NOT IN ANDROID
Exception: java.lang.NumberFormatException: For input string: "6.24 "
However in the java program running on my machine it fails when parsing it? in Android it carries on fine.
I have noticed one thing different when testing. When printing the value of "height4" in eclipse on my machine it outputs something like this: HEIGHT4 = '6.24 ' <--Notice the space!
In Android it outputs this: HEIGHT4 = '6.24'<--No Space?
Nothing is different between the 2 bits of code except the platform they are running on( as far as I can see).
What could the cause of this be? Something to do with that un-removable whitespace?