Man, I recently made a thread like this. I ended up implementing a HashMap and writing it to a file. I used Serializables, although apparently there are some alternatives that are more effective than Java's built in Serialization. The save data might be something like...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| public class SaveData { private HashMap saveData<String, Serializable>;
public void addProperty(String key, Serializable value) { saveData.put(key, value); }
public void removeProperty(String key) { saveData.remove(key); }
public void save() { }
public void load() { } } |
Keep in mind that not everything about an object can be serialized. The attributes of an object will become Serialized along with the object so long as they either implement the Serializable Interface, or are of a primitive data type. A HashMap implements the Serializable interface, so it is fair game.
Yeah, and this code won't run... Haven't tested it. Just demonstrates.