Serializing Unserializable Classes
- Some classes are not serializable
- Example: Ellipse2D.Double
- How can we serialize Car?
- Suppress default serialization to avoid exception
- Mark with transient:
private transient Ellipse2D frontTire;
- Supply private (!) methods
private void writeObject(ObjectOutputStream out)
private void readObject(ObjectInputStream in)
- In these methods
- Call writeDefaultObject/readDefaultObject
- Manually save other data
- Ch7/serial/Car.java