-1

I seem to be getting java.util.InputMismatchException when reading from a file. The file is just an array of numbers

Please advise.

package assignment1;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Question4 {

public static void main(String[] args) throws FileNotFoundException 
{

    Scanner inFile = 
              new Scanner(new FileReader("glassdatatxt.txt"));

    Double [][] glassdata = new Double[214][11];

    for(int row = 0; row < glassdata.length; row++)
    {
        for(int col = 1; col < glassdata[row].length; col++)
        {
           glassdata[row][col] = inFile.nextDouble();
        }
    }


    for(int row = 0; row < glassdata.length; row++)
    {
        for(int col = 1; col < glassdata[row].length; col++)
        {
            System.out.print(glassdata[row][col] + " ");
        }
        System.out.println();
    }

}

}
HaveNoDisplayName
  • 7,711
  • 106
  • 32
  • 44
Avi
  • 29
  • 9
  • possible duplicate of [How to use Scanner to correctly read user input from System.in and act on it?](http://stackoverflow.com/questions/26446599/how-to-use-scanner-to-correctly-read-user-input-from-system-in-and-act-on-it) –  Sep 17 '15 at 06:52
  • I found my mistake earlier today. Thank you for all your help – Avi Sep 18 '15 at 07:27

1 Answers1

0

It was not reading the space character correctly. Initially I have commas in between the numbers. I replace the commas incorrectly. I got it to work now.

Avi
  • 29
  • 9