public static void main(String argv[]) throws Exception { FileOutputStream fos = new FileOutputStream("date.out"); ObjectOutputStream oos = new ObjectOutputStream(fos); Date date = new Date(); oos.writeObject(date); oos.flush(); oos.close(); fos.close(); } }
public static void main(String argv[]) throws Exception { FileInputStream fis = new FileInputStream("date.out"); ObjectInputStream ois = new ObjectInputStream(fis); Date date = (Date) ois.readObject(); System.out.PRintln("The date is: "+date); ois.close(); fis.close(); } }