Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

How to make somebody else's class serializable?

Thread view: 
Shawn - 03 Oct 2006 17:47 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.