Search

Sunday, October 10, 2010

What is serialization ?? How can we achieve it using Java and Why it is required ??

What ??
Serialization is the process of saving an object's state to a sequence of bytes; deserialization is the process of rebuilding those bytes into a live object.


How can we achieve it using Java ??


The Java Serialization API provides a standard mechanism for developers to handle object serialization


A Typical Serialization Algorithm does following:



  • It writes out the metadata of the class associated with an instance.
  • It recursively writes out the description of the superclass until it finds java.lang.object.
  • Once it finishes writing the metadata information, it then starts with the actual data associated with the instance. But this time, it starts from the topmost superclass.
  • It recursively writes the data associated with the instance, starting from the least superclass to the most-derived class.

No comments:

Post a Comment