• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need of Externalizable  RSS feed

 
Kartik Patel
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!