File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "Serializing a class in Java" Watch "Serializing a class in Java" New topic

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.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
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.
I agree. Here's the link:
subject: Serializing a class in Java
It's not a secret anymore!