Originally posted by Bob Graffagnino:
How does one write to an existing (non-empty) file without overwriting its contents? It's my understanding that FileWriter and FileOutputStream will overwrite an existing file. RandomAccessFile will work, but does RAF support character encoding?
Thanks!
Graff.
If you take a close look at the constructors available for FileOutputStream, you'll notice that there is one that takes a
String for the filename and a boolean that says whether you'd like to append data or not. You can find that constructor
here.
Just set that second parameter to true and
you should be all set.
Corey