I get java.util.inputmismatchexception when using nextDouble() on a file containing only doubles. Here is the relevant section of code:
public static double[] getGravity() throws IOException
{
Scanner file = new Scanner("SurfaceGravity.txt");
double[] gravity = new double[8];
for(int index = 0; index < gravity.length; index++)
gravity[index] = file.nextDouble(); //Here is where I get the error
file.close();
return gravity;
}
And here is the contents of SurfaceGravity.txt
3.700465457603474
8.8661999605471
9.8
3.697967684866716
24.776754466506414
10.43814587026926
8.861473215210253
11.131680688084042
0.6128071987535232
I was under the impression that inputmismatchexception occurs when the token is the wrong type but as far as I can tell all of the tokens in the file are doubles so I am a bit confused.