What is the difference between Serializable - writeObject () / ReadObject and Externalizable - readExternal () / writeExternal () in Java?

I understood from this publication that Serializable is incredibly easy to implement and resilient to change (in most cases, all you have to do is update the serialversionUID). If we want to control the process of reading and writing, we can implement Externalizable.

If all we want is to control the process of reading and writing, we can override the methods below for serialization. Why do we need to introduce a new Externalizable interface?

private void writeObject(java.io.ObjectOutputStream out)
     throws IOException
 private void readObject(java.io.ObjectInputStream in)
     throws IOException, ClassNotFoundException;
 private void readObjectNoData()
     throws ObjectStreamException;
+4
source share
1 answer

You are asking:

Externalizable?

, ( Oracle), WebLogic JMS Best Practice:

" Java . , , JMS. - , java.io.Externalizable, . , Object, Externalizable readExternal writeExternal. , obj.writeExternal(stream), stream.writeObject(obj). Bytes Stream .

, , Externalizable, .

"" , Serializable, , Externalizable .

+3

Source: https://habr.com/ru/post/1543801/


All Articles