Hi,
I am using somebody else's Class file, which is also used by many other
people. The class file doesn't implements interface Serializable. Now, I
"wish" to write/save the object and later read/retrieve it by using
object serialization.
It is hard to request somebody changing his class file just becasue it
is convenient for me. Since it has been so for many years. (I will try
to ask him too.) I am wondering if it is possible to achieve my purpose
solely by my coding effort.
Thank you very much.
Thomas Hawtin - 03 Oct 2006 18:22 GMT
> I am using somebody else's Class file, which is also used by many other
> people. The class file doesn't implements interface Serializable. Now, I
> "wish" to write/save the object and later read/retrieve it by using
> object serialization.
If you can subclass it, you can read and write the data yourself from
readObject/writeObject.
If you need to pass values to the constructor, you can use
readResolve/writeReplace:
http://groups.google.com/group/comp.lang.java.programmer/tree/browse_frm/thread/
88dca62e39be2a90/
Tom Hawtin
Arne Vajhøj - 04 Oct 2006 03:23 GMT
> I am using somebody else's Class file, which is also used by many other
> people. The class file doesn't implements interface Serializable. Now, I
[quoted text clipped - 5 lines]
> to ask him too.) I am wondering if it is possible to achieve my purpose
> solely by my coding effort.
Maybe you can use this:
http://www.javageeks.com/Papers/SerializableAdapter/SerializableAdapter.html
Arne