• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object Output Stream  RSS feed

 
Ronald Spina
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Can some body help me how to write a method so that I can store object on a persistent stream. E.g. any text file.

I would like to use this method below: -

[/code]

If anybody has some examples please forward.
Thanks a lot.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ronald Spina wrote:oos = newObjectOutputStream(fos);
out.writeObject();


Well, no, objects don't have names. You would pass a reference to the object you want to write. Since you already have some of the code, and obviously have an idea of what might be next, why not try it and see?

Note, however, that it will not be a text file. This is a binary format, not intended for human consumption. If you want something human readable (sort of), you could use java.beans.XMLEncoder/XMLDecoder.

If anybody has some examples please forward.


There's sure to be plenty on the web. Search for java serialization example or java writeObject example or even java io tutorial.

And welcome to the Ranch!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!