• Post Reply Bookmark Topic Watch Topic
  • New Topic

Serialization

 
Saran Ayyasamy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one explain me about what is serialization generally
and its implementation in JAVA?
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Put simply, serialization is the process of converting an entire Java object and all it's data and attributes into a serial form: a form that can be transmitted over a stream. Typically, Java objects are serialized and passed around using ObjectInput/Output Streams. The serialization is done automatically as part of the writeObject() method.
Serialized Java objects can be deserialized as well. That is, they can be read from an ObjectInputStream and reconstructed into an exact copy of the object that was serialized. Like serialization, deserialization is transparent, done as part of the readObject() method.
Serialized objects can be written to (and read from) files, which is a great way of permanently storing the state of an object for future use or reference.
http://java.sun.com/docs/books/tutorial/essential/io/serializing.html
Originally posted by Saran Ayyasamy:
Can any one explain me about what is serialization generally
and its implementation in JAVA?

[This message has been edited by Matt Senecal (edited September 27, 2001).]
[This message has been edited by Matt Senecal (edited September 27, 2001).]
 
Kai Middleton
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One very cool thing serialization can be used for is to do a deep copy without having to implement the cloneable interface on all of the objects contained within your object. Here is some example code:


I modified the above slightly from an example found here:

http://www.javaworld.com/javaworld/javatips/jw-javatip76.html
--Kai Middleton
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!