Monday, April 13, 2009

Object Serialization

Object Serialization transforms an object into a sequence of bytes so it cam be written to disc or can be transfer to the server. This Sequence of bytes can be later deserialized into an original object. After deserialization, the object has the same state as it had when it was serialized.

Java provides this facility through ObjectInput and ObjectOutput interfaces. The concrete implementation of ObjectOutput and OnjectInput interfaces is provided in ObjectOutputStream and ObjectInputStream classes respectively. These two interfaces have the following methods:

final void writeObject(Object obj) throws IOException
final Object readObejct() through IOException, ClassNotFoundException

The writeObject() method can be used be used to write any object to a stream, including strings and arrays and readObject() method can be used to read any stream as long as an object supports java.io.Serializable interface.

source: java-tips.org

No comments:

Computers Add to Technorati Favorites Programming Blogs - BlogCatalog Blog Directory