[Logo]
Forums Register Login
Need of Externalizable
Hi,
externalizable has methods readExternal and writeExternal which you override
now within these methods
you are using objectoutput's methods only right?
so what is the need of this interface anyway?
you can in your program anyway write directly ObjectOutputStream.writeXXX methods right?
 

Originally posted by Kartik Patel:
Hi,
externalizable has methods readExternal and writeExternal which you override
now within these methods
you are using objectoutput's methods only right?
so what is the need of this interface anyway?
you can in your program anyway write directly ObjectOutputStream.writeXXX methods right?



Externalization is a different way to "serialize" an object. When an object is serializable, it follows a particular way to convert the object into a bitstream and back. You can change it a bit by implementing readObject() and writeObject(), but basically, you are doing it only for the class in particular. The base classes will be handling their own serialization.

With Externalizable, the complete object, for that class, and its superclasses' is converted to the bit stream. The writeExternal() is responsible for the whole object at that point, including the base classes. On the read side, the default no-args constructor will be used, and then the readExternal() is responsible for the configuration of the instance.

Henry
[ February 26, 2007: Message edited by: Henry Wong ]
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards


This thread has been viewed 532 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 18, 2018 13:10:09.