How to append data to a file?

后端 未结 4 958
长情又很酷
长情又很酷 2020-11-30 14:43

I trying to write into the txt file.
But with out losing the data that is already stored in the file.

But my problem that when I put string in the txt file, the

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 14:57

    Use a FileWriter with second argument 'true' and a BufferedWriter:

    FileWriter writer = new FileWriter("outFile.txt", true);
    BufferedWriter out = new BufferedWriter(writer);
    

提交回复
热议问题