• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is toString() Invertible?  RSS feed

 
Greg Werner
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a file I am dumping large amounts of data to. One of the attributes I am interested in is List<Object> where Object is a class I have written. I have overwritten toString() in that particular object. So if I use PrintWriter and rely on the Object's to String method in writing that attribute to disk, can I recover it? Or do I have to specify my own way to encode that List in my file and decode it?
 
Kevin Workman
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Werner wrote:So if I use PrintWriter and rely on the Object's to String method in writing that attribute to disk, can I recover it?

No.
Greg Werner wrote:Or do I have to specify my own way to encode that List in my file and decode it?

Yes.

See also: http://java.sun.com/developer/technicalArticles/Programming/serialization/
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!