This example demonstrates how to use the writeObject
and
readObject
methods to encode custom data format. When there
is a large amount of persistent data, that data should be stored in a
convenient, condensed format.
This example uses a triangular array, a symmetrical, 2-dimensional array.
During serialization, only half of the array will be saved. This example
serializes half of the array in writeObject
and then restores
the whole array in readObject
by deserializing half of the
array and copying to restore the other half of the array.
This example differs from the
Serialization and the Serializable Fields API Example in that this
example does not support versioning. In addition, because this example
does not use an Externalizable interface, superclasses are not a
consideration.