inputMismatchException Java reading doubles from plain text file
- by user939287
Using
double variable = inputFile.nextDouble();
Gives the mismatch error and I can't figure out why... Anyone know what's up?
The input file is just a bunch of doubles like 5.0...
Okay here is the code snippet
String fileName;
Scanner scanner = new Scanner(System.in);
System.out.println("\nEnter file name that contains the matrix and vector: ");
fileName = scanner.nextLine();
Scanner inputFile = new Scanner(fileName);
double a1 = inputFile.nextDouble();
the input file is a plain text document .txt in this format
5.0 4.0 -3.0
4.0 2.0 5.0
6.0 5.0 -2.0
-13.0 4.0 12.0
I don't understand why it wouldn't take those as doubles...
As far as what its expecting the format of the file to be... I suppose binary? isn't that the default? I didn't specify in the code...