Hey, i’m pretty new to java, and i need some help with a simple maze game that i’m trying to do. First, i want to draw a maze by reading from a file, and storing that information into a 2d array. The fill will have 1s and 2, where 1 represents a wall and 2 represents a corridor. Here is what i have so far:
StringTokenizer tokenizer;
String line, file = “map.txt”;
int map [][] = new int [13][15];
try
{
FileReader fr = new FileReader(file);
BufferedReader inFile = new BufferedReader (fr);
line = inFile.readLine();
while (line != null)
{
tokenizer = new StringTokenizer (line);
for(int row = 0; row < 13; row++)
{
for (int col = 0; row < 15;col++)
{
map[row][col]=Integer.parseInt (tokenizer.nextToken());
}
}
line = inFile.readLine();
}
inFile.close();
}
catch (FileNotFoundException exception)
{
System.out.println ("The file " + file + " was not found.");
}
catch (IOException exception)
{
System.out.println (exception);
}
}
The problem is, when i run appletviewer, i get a NoSuchElementException, if anyone can help, i’d be really greatful