Basic HTML version of Foils prepared 17 Nov 97

Foil 40 Object Serialization

From Java Tutorial, July 1, 1996 CEWES Tutorial, CPS606, JSU Class CSC499 -- July 22-25 1997, Fall 97. by Nancy J. McCracken,Geoffrey C. Fox, Tom Scavo


1 Classes ObjectOutputStream and ObjectInputStream in package java.io implement object serialization.
2 Java objects are serialized with writeObject() and deserialized with readObject(). For example:
3 Vector lines = new Vector( 256 ); ...
4 try {
  • new ObjectOutputStream(
  • new GZIPOutputStream(
  • new FileOutputStream( filename ) ) );
  • out.writeObject( lines );
  • out.close();
5 } catch ( IOException e ) { }
6 Only objects of classes that implement Serializable (or Externalizable) can be serialized. (The Serializable interface defines no methods.)
7 Object variables not to be serialized are called transient.

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998