1 import java.io.*; 2 3 public class TestObjectOutputStream { 4 public static void main(String[] args) throws IOException { 5 try ( // Create an output stream for file object.dat 6 ObjectOutputStream output = 7 new ObjectOutputStream(new FileOutputStream("object.dat")); 8 ) { 9 // Write a string, double value, and object to the file 10 output.writeUTF("Jamal"); 11 output.writeDouble(85.5); 12 output.writeObject(new java.util.Date()); 13 } 14 } 15 }