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

Problem with read-write methods in Serialization

 
Lalit Bansal
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
During serialization, if I'm implementing my own writeObject & readObject methods then which method should I use to read a String.

Please view the following code:



Here I've written a String using writeChars() methods while serializaing object. But there is no similar method while reading object during de-serialization.

Can anyone help me out in same.

NOTE - I know that we can do same using defaultWriteObject()/defaultReadObject() methods. But I intentionaly want to go this way. Please provide a solution in the same context.
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Hi Lalit,

Even I checked the ObjectInputStream API and could not find any related method for reading a String. But can't we use public final Object readObject() method, as String extends Object. I haven't tried this, but just a thought.
 
Lalit Bansal
Ranch Hand
Posts: 63
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chandra,

It works with writeObject() and readObject() methods.

Thanks.

regards,
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic