File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Serializing a class in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Serializing a class in Java" Watch "Serializing a class in Java" New topic
Author

Serializing a class in Java

Raj Kumar Bindal
Ranch Hand

Joined: Apr 15, 2006
Posts: 418
I know we can serialize a class if that class implements Serializable/Externalizable interface. But, if a class doesn't implement any of these interfaces, can we still serialize that class in java. If Yes, please tell how.

Thanks in advance.

--Raj
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42917
    
  68
You can't, at least not through the binary mechanism using Object[In|Out]putStream. If the class follows JavaBean conventions you can use the java.beans.XMLEncoder/XMLDecoder classes , though.

As as aside, classes are not serialized, objects are.
 
 
subject: Serializing a class in Java