Can anyone explain to me in English what the Externalizable interface does? I tried to read the specks, but it quickly devolved into techno-babble about objects, I/O and Serializations. All I can make out is that the object that implements the Externalizable interface only has its identity written to the serialization stream and not its state? Why would you want that? And even though "it is the responsibility of the class to save and restore the contents of its instances" how exactly is this achieved? Thanks in advance Dan
Simply - I guess you write externalizable when you have an object which would implement serializable but have many class variables declared transient. So instead of writing transient all the time you just implement serializable and by implementing the required methods you tell the complier which are the variables you want to be serialized.
Hi Dan, The Externalizable interface gives programmers complete control over the serialization process. In certain circumstances, a programmer might not want the java.io.serialization to control the serialization. When you implement Externalizable you are telling the JVM that you will handle the complete loading and serializing of your object. You have to define the following 2 methods: readExternal and writeExternal You would probably using the readOject and writeObject methods from the java.io.ObjectStream class. Then you would need to perform the extra overhead that you require in either direction (i.e., refilling transient items, etc.). Regards, Manfred.