Reusing the Java (de)serialization in implementing Externalizable -


i implement java.io.externelizable says whatever java.io.serializable modifications. hooks, if any, there java serialization mechanism? alternatively there external libraries accurately emulate java serialization mechanism in open/extensible way?

you don't need implement java.io.externalizable small customizations serialization. implement java.io.serializable before , implement following 2 methods in class:

private void writeobject(objectoutputstream oos) {     oos.defaultwriteobject();     // custom serialization     oos.writeint(notserializableobj.getid()); }  private void readobject(objectinputstream ois) {     ois.defaultreadobject();     // custom de-serialization     notserializableobj = new notserializableobj(ois.readint()); } 

java.io.externalizable used when want change way object serialized (the underlying algorithm itself) performance or security reasons.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -