You can do the following:
- declare three special fields as transitional
- implement
writeObject(ObjectOutputStream out)in this method: - use
ObjectOutputStream.defaultWriteObject()to write all other default fields.
.
public class MyClass implements Serializable
{
private void writeObject(java.io.ObjectOutputStream out) throws IOException
{
out.defaultWriteObject();
}
private void readObject(java.io.ObjectInputStream in) throws IOException
{
in.defaultReadObject();
}
private transient int special1;
...
}