I'm making a map editor for my game and I'm at the point where I need to save the map to a file. My Maps contain multiple layers though, which will be stacked on eachother for display. I know I could save each file seperately but I wanted these to be contained in a single file.

Is there an easy way to do this that I'm not thinking about? TIA

How about XML? Or Does Java Support Serialisation?

Yup
XMLEncode and XMLDecode will convert anything bean-like to XML dead easily. Also works for beans-within-beans, so you can encode/decode an entire List, or arbitrary top-level container object in just one method call.

You could also create a zip file with all your files in it (java.util.zip.*)

"Real" game maps are almost always stored as binary to reduce load time and to prevent easy editing using a text editor (some sort of obfuscation).

http://gamedev.stackexchange.com/questions/35893/custom-extensible-file-format-for-2d-tiled-maps

Also, if you have got simplistic sort of data you can use existing binary formats like protocol buffer for encoding your data.

https://github.com/bjorn/tiled/wiki/TMX-Map-Format

The obvious disadvantage being requiring more work and not being human readable. It really depends though, go with XML/JSON if you are not going to have crazy big maps...

If you want to have fun with "from scratch development", try implementing binary maps, if not, just go with the simplest possible XML representation.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.