Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with code at line 82 of the TileManager #3

Open
mzahoran opened this issue May 2, 2023 · 2 comments
Open

Issue with code at line 82 of the TileManager #3

mzahoran opened this issue May 2, 2023 · 2 comments

Comments

@mzahoran
Copy link

mzahoran commented May 2, 2023

I am having issues with the code where we parseInt the String numbers[ ] where we read the map data. I am not sure where my issue lies but I cannot for the life of me figure it out. I'll post the code and if you think you could point in the right direction . It would be much appreciated.

public void loadMap(String filePath) {

	try {
		InputStream is = getClass().getClassLoader().getResourceAsStream(filePath);
		BufferedReader br = new BufferedReader(new InputStreamReader(is));
		
		
		int col = 0;
		int row = 0;
		
		while(col < gp.maxWrldCol && row < gp.maxWrldRow){
			String line = br.readLine();
			
			
			while(col < gp.maxWrldCol) {
				String numbers[] = line.split(" ");
				int num = Integer.parseInt(numbers[col]);     _***////* this is where i recieve a NumberFormatException.**_
				mapTileNum[col][row] = num;
				col++;
			}
			if(col == gp.maxWrldCol) {
				col = 0;
				row++;
			}
			
		}
		br.close();
		
	}catch(Exception e) {
		e.printStackTrace();
	}
}
@LordRekishi
Copy link
Owner

What do you mean issue? What's happening? What's the error?

@mzahoran
Copy link
Author

mzahoran commented May 2, 2023

On the line where it parseInt the String numbers. It is throwing a numberFormatException. I know it's supposed to clear the space between the numbers and return a int from the string we use to read the map data. I'm just not 100 percent sure where my issue lies. Let me know if you would need to see my entire code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants