Serializing object

JAVA PRIMER
Using Java Object Serialization: A Few Pitfalls
Huw Evans
Listing 1. Serializing object "o" to the file "store."


1   import java.io.*;
2   public class Serialize
3   {
4     public static void main(String argv[])
5     {
6       ObjectOutputStream out = null;
7       FileOutputStream file = null;
8       try {
9         file = new FileOutputStream("store");
10        out = new ObjectOutputStream(file);
11         O o = new O();
12         out.writeObject(o);
13         out.close();
14       } catch(java.io.IOException ioe) {
15         ioe.printStackTrace();
16         System.exit(1);
17       }
18     }
19   }

Upcoming Training Events

0 AM
Visual Studio Live! San Diego
September 8-12, 2025
Live! 360 Orlando
November 16-21, 2025
Cloud & Containers Live! Orlando
November 16-21, 2025
Data Platform Live! Orlando
November 16-21, 2025
Visual Studio Live! Orlando
November 16-21, 2025