Use ObjectOutputStream and FileOutputStream with FileWriter

Posted by wishi on Stack Overflow See other posts from Stack Overflow or by wishi
Published on 2011-01-17T13:48:36Z Indexed on 2011/01/17 13:53 UTC
Read the original article Hit count: 196

Filed under:
|

Hi!

Is there any way to use ObjectOutputStream like this:

<tag>output of the ObjectOutputStream</tag>

If I try:

FileOutputStream fos = new FileOutputStream(filename);
ObjectOutputStream oos = new ObjectOutputStream(fos);
FileWriter fw = new FileWriter(fos);

And for example:

fw.write("<tag>");
oos.write(cool_object);
fw.wrote("</tag>");

I don't get that result. It seems the ObjectOutputStream overwrites the file completly each and every time.

© Stack Overflow or respective owner

Related posts about java

Related posts about objectoutputstream