File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Custom Serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Custom Serialization " Watch "Custom Serialization " New topic

Custom Serialization

Kumar Kausikasa
Ranch Hand

Joined: Jun 04, 2002
Posts: 45
Hi ,
I have a question about custom serialization. I read about serialization on sun'web site.
According to the above document, if i want to change the way i control serialization and deserialization process , i need to overide writeObject and readObject method.
But if i want to have the total control ( including the methods used for serilaization)i need to implement Externalizable interface which has readExternal and writeExternal methods.
So i guess, in the first case it is using java standard object serialization.
But in case of Externalizable interface, i can specify my own serialization mechanism.
Please correct me, if the above statement is wrong.
If i decide to implement Externalizable, can some one provide me links where i can find examples of such implementation.
can some one throw light on the techniques and methods to improve the serialization ( example improving the speed of serialization).
Thanks very much for your time.
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1873
hi Praveen
ur prediction about how serializable and externalizable used is correct. serializable customization via implementing private void writeObject() and readObject() uses standard mechanism and used in special cases like one mentioned in the link you provided (that PersistanceThread thing) and externalizable is used to have complete control over things..
it seems both of ur questions,
1. provide an example using Externalizable
2. how to improve serialization performance
can probably answered by,
JDC Tech Tip

Kumar Kausikasa
Ranch Hand

Joined: Jun 04, 2002
Posts: 45
Thank you Maulin.
Yes, this was the link i was looking.
I agree. Here's the link:
subject: Custom Serialization
It's not a secret anymore!