import java.io.*;
public class Point implements Serializable {
private int x;
private int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public String toString() {
return "(" + x + "," + y + ")";
}
public static void main(String[] args)
throws IOException, ClassNotFoundException {
Point a = new Point(1,2);
File f = File.createTempFile("tempFile","test");
f.deleteOnExit(); ObjectOutputStream out =
new ObjectOutputStream(new FileOutputStream(f));
out.writeObject(a); out.close();
ObjectInputStream in =
new ObjectInputStream(new FileInputStream(f));
Point aPrime = (Point) in.readObject(); in.close();
System.out.println("a = " + a);
System.out.println("aPrime = " + aPrime);
System.out.println("Egalité = " + (a == aPrime));
}
}