public class SerializeCarTester
1: import java.io.*;
3: /**
4: A program that serializes and deserializes a car.
5: */
6: public class SerializeCarTester
7: {
8: public static void main(String[] args)
9: throws IOException, ClassNotFoundException
10: {
11: Car beemer = new Car(100, 100, 60);
12: System.out.println(beemer);
13: ObjectOutputStream out = new ObjectOutputStream(
14: new FileOutputStream("fleet.dat"));
15: out.writeObject(beemer);
16: out.close();
17: ObjectInputStream in = new ObjectInputStream(
18: new FileInputStream("fleet.dat"));
19: System.out.println(in.readObject());
20: in.close();
21: }
22: }