This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please explain writeObject() ...

 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I am using ObjectOutputStream and writeObject,
and I am trying to write two Strings in it.
Okay, so it compiles, but it would be nice to understand how JAVA knows where the field "model" ends and the next field "colour" starts.
I mean : if we were to use readObject(), how does the read know there are 2 fields ???


Sometimes I really like to know why JAA works in a particular way. I see it as an overly complex language.
[ November 21, 2002: Message edited by: achana chan ]
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is not a Servlet specific question so I am moving it to Java Intermediate.
 
Pete Lyons
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Serialization Tutorial explains some of how serialization works. If you're curious, detailed explainations of the binary format can be found on the web, or just open the file up in a text editor. Basically, you should not need to worry about the implementation details, which is why it's easy to serialize objects in some languages. Of course, the source code to ObjectOutputStream is always there for the real truth. You also might be curious about java.beans.XMLDecoder to see an alternate file format for the stored object graph.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic