Serialisation problems.

I am programming a game and have now turned towards the load/save functionality. Instead of designing documents describing all parameters that need to be saved I instead plan to save objects using Serialization :smiley:

Not sure how many kilobytes or even Megabytes that will result in. I have experienced that there are some classes from the Java API that needs to be made transient. java.awt.Image is one of them it seems. I store Images inside objects, but instead i could just save the String name of the Image and use createImage everytime i call “getImage()” on the object. I am not sure if that will slow the game down, but once loaded, the Image should be in the heap-memory for later hence quick access?

Anyway, I have some options to choose from and I wanna use the most neat option that works long term and is scaleable (since I do not know if there might be many more classes out there that will face the same problem)

  1. Storing Strings instead of images and creating Image with method call
  2. Use transient
  3. Using extended classes of for instance java.awt.Image and make them implement the Serializable Interface

If some of my Objects I store have fields which are vectors, will storing the Object manage to store the Vector and all the objects inside?

make them transient and handle storing and retrieving them yourself.

yes if your vector and all object inside implments Serializable but as mentionned above, you will save a lot of memory by overloading the writeObject and readObject method and doing that work by yourself