I know this is probably very basic but I have been trying for hours and still can't figure this out on my own. So right now I am doing the 8 puzzle game for my AI class. I need the user to enter a series of numbers, say: "032 145 678" and I need to simply store this into a 3x3 matrix, where 0 will basically represent an empty block. So it should take that user input and store it like {{032},{145},{678}}, a 3x3 matrix.
EDIT:
public void ReadFromTxt(String file) throws FileNotFoundException, IOException {
String read;
FileReader f = new FileReader(file);
int i = 0;
int j;
BufferedReader b = new BufferedReader(f);
System.out.println("Loading puzzle from file...");
while((read = b.readLine())!=null){
if(read.length()==3){
for(j=0;j<3;j++){
board[i][j] = (int)(read.charAt(j)-48);
}
}
i++;
}
b.close();
System.out.println("Puzzle loaded!");
}