All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.pdx.cs.joy.net.ReadDate Maven / Gradle / Ivy

The newest version!
package edu.pdx.cs.joy.net;

import java.io.*;
import java.util.*;

/**
 * This class demonstrates object serialization by reading an instance
 * of Date from a file.
 */
public class ReadDate {

  /**
   * Read a Date instance from th file whose name is
   * specified on the command line.
   */
  public static void main(String[] args) {
    String fileName = args[0];

    Date date = null;
    try {
      FileInputStream fis = new FileInputStream(fileName);
      ObjectInputStream in = new ObjectInputStream(fis);
      date = (Date) in.readObject();
      in.close();
      System.out.println("Read " + date);

    } catch (ClassNotFoundException ex) {
      System.err.println("** No class " + ex);
      System.exit(1);

    } catch (IOException ex) {
      System.err.println("**IOException: " + ex);
      System.exit(1);
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy