Certain data fields should never be serialized—for example, integer values that store file handles or handles of windows that are only meaningful to native methods. Such information is guaranteed to be useless when you reload an object at a later time or transport it to a different machine. In fact, improper values for such fields can actually cause native methods to crash. Java has an easy mechanism to prevent such fields from ever being serialized. Mark them with the keyword
transient. You also need to tag fields as
transient if they belong to nonserializable classes. Transient fields are always skipped when objects are serialized.
The serialization mechanism provides a way for individual ...