How to write to a text file concatenating with existing text in Java?

3

I would like to write to a text file using Java, but whenever I am going to use the write BufferedWriter functions the previous text is deleted and the new text is written, I would like to keep the old text and just concatenate the new.

    
asked by anonymous 05.02.2014 / 14:58

2 answers

2

Add text to existing text you need to open the file with APPEND mode. You can tell this in the FileWriter constructor. FileWriter(String fileName, boolean append)

Example:

Writer arquivo = new BufferedWriter(new FileWriter("arquivo", true));
arquivo.append("Mais conteudo");
arquivo.close();

I saw here .

    
05.02.2014 / 15:07
1

Before building BufferedWriter , create a < to% d of%

05.02.2014 / 15:09