Reputation: 149
I have several objects that I serialized and now need to edit, is there an approach to this without losing all the data I had stored in the files using the serialization.
EDIT [from comment] I dont need to edit the objects themselves I need to edit the Objects code, such as adding methods to it.
Upvotes: 0
Views: 72
Reputation: 311031
I dont need to edit the objects themselves I need to edit the Objects code, such as adding methods to it
Aha. An actual problem. OK.
Run the serialver
utility on the .class files as they are now.
Add the declarations output by serialver
to the source code of each class respectively.
Have a really good look at the Versioning chapter of the Object Serialization Specification to see what you can and cannot do while retaining compatibility with the existing stream.
Upvotes: 2
Reputation: 39477
Load the objects in memory, edit the objects themselves, then save them back.
This is the safest way of doing it (if not the only way).
Upvotes: 1