File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Serialization.........

 
Ganeshkumar cheekati
Ranch Hand
Posts: 362
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
readObject() and writeObject() methods are used for normal serialization and deserialization process...


defaultReadObject() and defaultWriteObject() methods are used to save the state of the object manually....


am i right?
 
Ankit Garg
Sheriff
Posts: 9497
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you got it wrong.

readObject and writeObject are used to serialize objects automatically.

If you want to manipulate the serialization process (like you would like to serialize a transient field), then you can override these methods. Then when an object of the class is serialized or deserialized, these methods are called by the JVM. If you want the automatic serialization to happen and then want to do some extra work during serialization, then you can call defaultReadObject and defaultWriteObject

eg
if you want your object to be written automatically, and add a line with "bye" at the end, then you will

override writeObject
call defaultWriteObject in the overriding method
manually write "bye" to the output stream...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic