aspose file tools*
The moose likes Beginning Java and the fly likes What is Serialization? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is Serialization?" Watch "What is Serialization?" New topic
Author

What is Serialization?

Rakesh Mehra
Ranch Hand

Joined: Nov 20, 2007
Posts: 31
What is Serialization?When and how do we implement it?Example real time environment application that uses Serialization?
abhishek pendkay
Ranch Hand

Joined: Jan 01, 2007
Posts: 184
Serialization
visit this page for all the info you need


The significant problems we face cannot be solved by the same level of thinking which created them – Einstein
SCJP 1.5, SCWCD, SCBCD in the making
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
For what is serialization you can read the link given above. Moreover, you can google serialization.

Implementing Serializable is bit tricky not that difficult though. YOu just need to take care of few things. Mainly, over-riding of readObject() method. For more you can refer to the book Effective Java from Joshua Bloch or try this link out.

Serilization is used in many ways when we need to send the objects over the network, or persist the objects on to storage device, etc.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Originally posted by Adeel Ansari:
Mainly, over-riding of readObject() method.

First of all, readObject is private so it isn't overridden. Instead, it is re-implemented.

Second, you only need readObject (and its partner in crime, writeObject) if you need to do some custom serialization, like serializing fields of a parent class that isn't serializable.


If you let a class implement java.io.Serializable, all primitive fields and serializable fields are serialized without any extra work. It's only when you need to store non-serializable fields or do any other custom work when readObject and writeObject come into play.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Originally posted by Rob Prime:
First of all, readObject is private so it isn't overridden. Instead, it is re-implemented.


Thanks for the correction. You can think of readObject() as a constructor whose sole argument is a byte stream.

Furthermore, making your class serializable is not a decision to be taken lightly.

Thanks.
[ November 27, 2007: Message edited by: Adeel Ansari ]
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
just some more data on previous responses...

Originally posted by Rob Prime:

... you only need readObject (and its partner in crime, writeObject) if you need to do some custom serialization, ...


including supporting over versions of your object,

for example, if you were using a data object to represent your document, and you updated the structure, you might want to be able to readObject() from old versions, then when you writeObject() it would be updated


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is Serialization?