I am trying to load a text file that contains characters and two numbers, something that looks like this
5 7
++++M++
+ + +
++ ++
+ ++ +
+X+++++
where the 5 and 7 correspond to number of rows and columns. I am trying to read this line by line and then translate the numbers into values in an array, however for some reason I fail to even
Scanner inputFile = new Scanner(new FileReader(fid));
maze_r = inputFile.nextInt();
maze_c = inputFile.nextInt();
int counter = 0;
while(inputFile.hasNextLine()){
rowArray = inputFile.nextLine();
System.out.print("\n"+rowArray);
char index;
for(int ind = 0; ind == (maze_c-1);ind++){
index = rowArray.charAt(ind);
System.out.print(index);
if(index == ' ')
theMaze[counter][ind] = 0;
if(index == '+')
theMaze[counter][ind] = 1;
if(index == 'M')
theMaze[counter][ind] = 2;
if(index == 'X')
theMaze[counter][ind] = 3;
}
}
System.out.print(Arrays.toString(theMaze));
}
When I do this it prints out the rows as characters but will print a void for the array I have tried to make. I do not know what I am doing wrong, for some reason it will not compute the for loop in the while loop. When I wrote like a system.out.print inside the loop nothing printed. What am I doing wrong?
counteris not getting incremented.