• Post Reply Bookmark Topic Watch Topic
  • New Topic

NullpointerException when reading from file

 
Marcus Setchell
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to read from a file that looks something like below



You get the picture, i had it working by storing each line in an array and the get a specific value using -
But now want to refine it to a 2d array but my new loop is throwing NullPointerExeption the code is below



All three of my file function are called from the constructor of my map class. Plus wasn't sure whether to post here or in game development forum but i thought more appropriate here.

Thanks in advance - Marcus.

Edit: Just for clarification i added the declaration of the Scanner m at the top.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is appropriate. Which line is throwing the null pointer?
 
Marcus Setchell
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahh I have sorted it, was the following -

Before -
After -

But thanks for taking the time to read this.

Marcus.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for sharing that you got it working and the solution!
 
Marcus Setchell
Greenhorn
Posts: 10
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome, at the end of the day forums are all about community and without people posting solutions, even for their own problems it does not benefit the community of people browsing.

Marcus.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!