Answer the question
In order to leave comments, you need to log in
How to use serialize as save?
Good afternoon.
For my home project, I made a save file through serialization.
Everything worked great.
But when there were changes in the classes for saving, the whole saving began to fall, although, according to the idea, only the changed classes should not be read.
But when you change one class, you get a ClassCastException or InvalidClassException on this line
Map<String, Object> saveMap = (HashMap<String, Object>) oin.readObject();
Answer the question
In order to leave comments, you need to log in
With standard serialization, this cannot be avoided in any way. I suggest using third-party libraries:
- json format - a lot of libraries for working with it, for example https://github.com/google/gson
- kryo - excellent and very fast serializer (!) - https://github.com/EsotericSoftware/ kryo -
protobuf
- also very good - https://developers.google.com/protocol-buffers/doc...
- xml format - a lot of libraries, even built into the JVM
or on kryo. But if cross-platform is needed, then protobuf.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question