import java.io.*;
public class ObjectInputTest {
  public static void main(String[] args) {
    ObjectOutputTest oot;
    ObjectInputStream ois = null;
    try {
      ois = new ObjectInputStream(
              new FileInputStream("test.ser"));
      Object o = ois.readObject();
      if (o instanceof ObjectOutputTest) {
        oot = (ObjectOutputTest) o;
        System.out.println("Object message is: " + oot.getMessage());       
        oot.setMessage("Goodbye!");
        System.out.println("New message is: " + oot.getMessage());
      } 
	  else {
        System.out.println("File is not the correct type");
      }
    } 
	catch (IOException ex) {
      ex.getMessage();
    } 
	catch (ClassNotFoundException ex) {
      ex.getMessage();
    } 
  }
}