Previous Page Next Page Start of Tutorial > Start of Trail > Start of Lesson Lesson Contents

Trail:
Essential Java Classes
Lesson:
Reading and Writing (but no 'rithmetic)



Help on searching
is available.

Search technology
by Excite, Inc.

Object Serialization

Two streams in java.io-- ObjectInputStream and ObjectOutputStream-- are run-of-the-mill byte streams and work like the other input and output streams. However, they are special in that they can read and write objects.

The key to writing an object is to represent its state in a serialized form sufficient to reconstruct the object as it is read. Thus reading and writing objects is a process called object serialization. Object serialization is essential to building all but the most transient applications. You can use object serialization in the following ways:

  • Remote Method Invocation (RMI)--communication between objects via sockets


    Note:  The client and server programs in Putting It All Together use RMI to communicate. You can see object serialization used in that example to pass various objects back and forth between the client and server.

  • Lightweight persistence--the archival of an object for use in a later invocation of the same program
As a Java programmer, you need to know about object serialization from two points of view. First, you need to know how to serialize objects by writing them to an ObjectOutputStream and reading them in again using an ObjectInputStream. The next section, Serializing Objects, shows you how. Second, you will want to know how to write a class so that its instances can be serialized. You can read how to do this in the section after that, Providing Object Serialization for Your Classes.
 
Previous Page Next Page Start of Tutorial > Start of Trail > Start of Lesson Lesson Contents

Michel RIVEILL

Laboratoire I3S - Bât. ESSI
930 Route des Colles
06903 Sophia Antipolis CEDEX

email : riveill at unice.fr

Généralité

Projet Rainbow

Ressources en lignes

Les rubriques des cours :

 

Rechercher sur ce site avec Google

 

dernière mise à jour
le 18 septembre 2003

 

 

Réservation d'Hôtel à Prix Réduits - HotelClub