OK, so I know I’ve posted ALOT in the last few days but I could really do with your help on this one.
The following code attempts to read a text file to obtain and store information about where it should put bricks(tiles) on the screen and what image it should paint them.
When run it tells me that it begins reading the file (due to a out.println) and then tells me that it has an error again due to println. I have put another println in for debugging purposes within the while loop and found that it doesn’t get past the first branch, I can’t see why, here’s the code:
{
String imsFNm = IMAGE_DIR + fnm;
System.out.println("Reading bricks file: " + imsFNm);
int numStripImages = -1;
int numBricksLines = 0;
try {
BufferedReader br = new BufferedReader( new FileReader(imsFNm));
String line;
char ch;
while((line = br.readLine()) != null) {
if (line.length() == 0) // ignore a blank line
continue;
System.out.println("Break 1");
if (line.startsWith("//")) // ignore a comment line
continue;
ch = Character.toLowerCase( line.charAt(0) );
if (ch == 's') // an images strip
numStripImages = getStripImages(line);
else { // a bricks map line
if (numBricksLines > MAX_BRICKS_LINES)
System.out.println("Max reached, skipping bricks line: " + line);
else if (numStripImages == -1)
System.out.println("No strip image, skipping bricks line: " + line);
else {
storeBricks(line, numBricksLines, numStripImages);
numBricksLines++;
}
}
}
br.close();
}
catch (IOException e)
{ System.out.println("Error reading file: " + imsFNm);
System.exit(1);
}
The debugging println prints “break 1”, but when ran it doesn’t reach this branch, this is the output it produces:
Reading bricks file: Images/bricksInfo.txt
Error reading file: Images/bricksInfo.txt
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
I know that the file paths are correct and that the code points to the right file, so I can’t explain this, any help would be appreciated, thanks.