//********************************************************************
//  ReadCountryInfo.java       Author: Lewis/Loftus
//
//  Demonstrates object deserialization.
//********************************************************************

import java.io.*;

public class ReadCountryInfo
{
   //-----------------------------------------------------------------
   //  Reads objects from a serialized file and prints them.
   //-----------------------------------------------------------------
   public static void main (String[] args) throws Exception
   {
      FileInputStream file = new FileInputStream ("countries.dat");
      ObjectInputStream inStream = new ObjectInputStream (file);

      CountryInfo[] countries = new CountryInfo[5];

      int scan;

      // Deserialize the objects
      for (scan = 0; scan < countries.length; scan++)
         countries[scan] = (CountryInfo) inStream.readObject();

      // Print the objects
      for (scan = 0; scan < countries.length; scan++)
         System.out.println (countries[scan]);
   }
}
