I am attempting to run a Sudoku game code in java (Using NetBeans) and am currently writing the method that initializes the game and reads the file containing the starting game code. The text file reads as so:
0,0,2,9,8,0,5,0,0
4,0,0,0,7,0,0,1,3
0,3,9,6,0,4,0,7,0
2,0,0,0,5,6,4,0,0
8,4,0,3,0,0,2,0,1
9,0,7,0,0,1,0,8,6
6,0,0,7,0,5,1,3,0
0,9,1,4,0,0,0,0,5
0,2,0,0,3,0,6,0,8
My current code being run is:
Scanner f = new Scanner(new FileReader("C:(MY FILE LOCATION)"));
for (int i = 0; i < 9; i++) {
line = f.next();
readLine = line.split(",");
for (int j = 0; j < 9; j++) {
gameBoard[i][j] = readLine[j];
}
}
The NullPointerException comes from the line of code:
gameBoard[i][j] = readLine[j];
When I don't declare the numbers to the game board and just print them out instead it works just fine. I already having it throwing FileNotFoundException. Thanks for any help!