[Solved] Reading world from a file

Hi

For my current project a read [icode]Block[/icode] objects from a file. While I am doing this, the first block is read completely, but the other blocks don’t seem to be read? I know this is specific to my project, and I don’t know if I provided enough code, but I was wondering if someone could help me out with this issue, as the plan is to have many blocks read from this file, and there must be a lot of files if only one block can be read from a file. Hope somebody can help :slight_smile:

WorldReader constructor pastebin: http://pastebin.java-gaming.org/aa3543c1d001b

CopyableCougar4

Have you tried printing out the size of your array?

What is in your readFileToList() function?

Hi

The readFileToList just constructs a buffered reader for the file, and the arrays of both tiles and the list of file lines both have the expected number of spaces, it’s just that for two of the blocks all the Tile objects in the arrays are null.

CopyableCougar4

Hi

I feel stupid looking back at my code… I just didn’t reset the y value every section, and I had a try-catch for the [icode]ArrayIndexOutOfBoundsException[/icode], so I didn’t see the error.

CopyableCougar4

Never catch bounds errors, or if you do, at least print the trace. Always print/log errors.