import java.awt.Color;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
class Dog implements Serializable {
transient private Color theColor;
private int dogSize;
public Dog(Color collar, int size) {
theColor = collar;
dogSize = size;
}
public Color getColor() {
return theColor;
}
private void writeObject(ObjectOutputStream os) {
// throws IOException {
try {
os.defaultWriteObject();
os.writeInt(theColor.getRGB());
} catch (Exception e) {
e.printStackTrace();
}
}
private void readObject(ObjectInputStream is) {
// throws IOException, ClassNotFoundException {
try {
is.defaultReadObject();
theColor = new Color(is.readInt());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|