Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serializing a class in Java

 
Raj Kumar Bindal
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic