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 Serialization -  Seriallizable   Vs  Externalizable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Serialization -  Seriallizable   Vs  Externalizable" Watch "Serialization -  Seriallizable   Vs  Externalizable" New topic

Serialization - Seriallizable Vs Externalizable

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1432
a). Which is the optimized way(Seriallizable Vs Externalizable) of doing serialization?
b). If i use transient / volatile fields in serializable class any difference in using Seriallizable and Externalizable.
Greg Charles

Joined: Oct 01, 2001
Posts: 2969

Probably Serializable will work best for you. Externalizable is a subinterface of Serializable, which gives you more control over how your objects are serialized and de-serialized ... though at the expense of having to write a lot more code yourself.

The volatile keyword doesn't affect serialization in any way. Member variables marked transient are not serialized from normal Serializable classes, but for Externalizable classes, you decide what gets serialized and what doesn't, so it seems to me that the transient keyword wouldn't do anything.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46412
See whether you can find a copy of Bruce Eckel's Thinking in Java, which has a chapter about serialisation. The 3rd edition used to be available free of charge on the Net.
I agree. Here's the link:
subject: Serialization - Seriallizable Vs Externalizable
It's not a secret anymore!