001package horstmann.ch07_serial2; 002import java.io.FileInputStream; 003import java.io.FileOutputStream; 004import java.io.IOException; 005import java.io.ObjectInputStream; 006import java.io.ObjectOutputStream; 007 008/** 009 A program that serializes and deserializes a car. 010 */ 011public class SerializeCarTester 012{ 013 public static void main(String[] args) 014 throws IOException, ClassNotFoundException 015 { 016 Car beemer = new Car(100, 100, 60); 017 System.out.println(beemer); 018 ObjectOutputStream out = new ObjectOutputStream( 019 new FileOutputStream("fleet.dat")); 020 out.writeObject(beemer); 021 out.close(); 022 ObjectInputStream in = new ObjectInputStream( 023 new FileInputStream("fleet.dat")); 024 System.out.println(in.readObject()); 025 in.close(); 026 } 027}