Using Strings as Mementos
Object serialization provides a simple means for a memento to persist across multiple sessions that occur, say, on a given day. If, on the other hand, your user wants to revive a simulation after a six-month sabbatical, he or she may find that various classes in the simulation package have evolved to new versions. The java.io package provides some support for deserializing an object when its class has changed since the serialization was written, but proper handling of object serialization across class versions is, in practice, problematic. To avoid this problem, you can “serialize” your object to text.
One way to provide persistent storage of an object is to write out a textual description of it. You can save an object's ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access