Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

What is use of serialization?
Serialization can be obtained in a class by implementing the 
java.io.Serializable interface. All the subclasses of a serialized
class are also themseleves serialize. This interface contains no 
methods and used simply to identify being serialized.
Its main purpose is to save the object state into a device or file
for the future use. This process is calles serialization. 
When we want to access the state of the object we make it deserialized.
The classes that require serialization must implement the 
following methods for the serialization and deserialization process.

private void writeObject(java.io.ObjectOutputStream out)
     throws IOException{
//write the object state
}
 private void 
readObject(java.io.ObjectInputStream in)
     throws IOException, ClassNotFoundException{
//read the object state
}
   
The writeObject() method is responsible for saving the state 
of the object into a resource, i.e. device or a file. The readObject()
method is responsible for the accessing the object state.
Posted By: Name:Rajesh Kr URL: What is use of serialization?