001package edu.pdx.cs410J.net;
002
003import java.io.*;
004import java.util.*;
005
006/**
007 * This class demonstrates object serialization by reading an instance
008 * of <code>Date</code> from a file.
009 */
010public class ReadDate {
011
012  /**
013   * Read a <code>Date</code> instance from th file whose name is
014   * specified on the command line.
015   */
016  public static void main(String[] args) {
017    String fileName = args[0];
018
019    Date date = null;
020    try {
021      FileInputStream fis = new FileInputStream(fileName);
022      ObjectInputStream in = new ObjectInputStream(fis);
023      date = (Date) in.readObject();
024      in.close();
025      System.out.println("Read " + date);
026
027    } catch (ClassNotFoundException ex) {
028      System.err.println("** No class " + ex);
029      System.exit(1);
030
031    } catch (IOException ex) {
032      System.err.println("**IOException: " + ex);
033      System.exit(1);
034    }
035  }
036
037}