ficheros java

super nais
01 de Abril del 2006
A ver si alguien me puede ayudar. Estoy intentando guardar datos en un fichero, pero cada vez que arranco mi aplicacion me crea el fichero nuevo, aunke ya exista, por lo que se me borran los datos anteriores. Lo hago así:
DataOutputStream dos = new DataOutputStream (new BufferedOutputStream (new FileOutputStream ("fichero.txt")));
dos.writeChars("hola");

Diego
01 de Abril del 2006
todo lo que huela a archivos... huele a File.
donde pones:
new FileOutputStream ("fichero.txt")
pon:
new FileOutputStream ("fichero.txt",true)
Según la documentación del jdk, debe hacer esto:
Creates an output file stream to write to the file with the specified name. If the second argument is true, then bytes will be written to the end of the file rather than the beginning. A new FileDescriptor object is created to represent this file connection.

... es decir, los bytes serán escritos al final del archivo en lugar de al principio. Espero que te sirva.