I am trying to get a sudoku verifier working by reading in txt file with comma-seperated digits. My code reads the first line into the array then when going to the next line throws an InputMismatchException error. I've tried looking things up but nothing has worked. This is my code along with what the txt input file contains
String fileName = "data/sudoku-valid-1.txt";
Scanner s = null;
try {
s = new Scanner(new File(fileName));
s.useDelimiter(",");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
int array[][] = new int[9][9];
int i, j;
while(s.hasNext()) {
for(i=0; i<9; i++) {
for(j=0; j<9; j++) {
array[i][j] = s.nextInt();
}
}
}
Txt file:
1,5,7,9,8,3,6,2,4,
2,6,8,7,5,4,9,3,1,
9,4,3,6,1,2,7,5,8,
8,9,2,1,7,6,5,4,3,
3,1,6,5,4,8,2,7,9,
5,7,4,3,2,9,1,8,6,
7,3,5,4,6,1,8,9,2,
6,8,9,2,3,5,4,1,7,
4,2,1,8,9,7,3,6,5,