1 import java.io.*; 2 3 public class TestObjectInputStream { 4 public static void main(String[] args) 5 throws ClassNotFoundException, IOException { 6 try ( // Create an input stream for file object.dat 7 ObjectInputStream input = 8 new ObjectInputStream(new FileInputStream("object.dat")); 9 ) { 10 // Read a string, double value, and object from the file 11 String name = input.readUTF(); 12 double score = input.readDouble(); 13 java.util.Date date = (java.util.Date)(input.readObject()); 14 System.out.println(name + " " + score + " " + date); 15 } 16 } 17 }