Sunday, December 20, 2009

Externalizable interface extends java.io.Serializable, whereas this interface comes with two methods to store and retrieve data from Object Stream and this is not marker interface. This approach gives luxury of deciding to application developer, what to be serilized and what not to be. However, this technique enforces that the order in it stored in stream, the same order, has to be used to read back.

If number of read operations is not equivalent in readExternal to write operations in writeExternal then following Exception

Exception in thread "main" java.io.OptionalDataException at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1349) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at ExternalizableTest$EmployeeBean.readExternal(ExternalizableTest.java:42) at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1792) at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1751) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at ExternalizableTest.main(ExternalizableTest.java:65)

0
comments:

Post a Comment

Recent Posts

Texts

This blog intended to share the knowledge and contribute to JAVA Community such a way that by providing samples and pointing right documents/webpages. We try to give our knowledege level best and no guarantee can be claimed on truth. Copyright and Terms of Policy refer blogspot.com