Write to text file without overwriting in Java

前端 未结 9 1356
失恋的感觉
失恋的感觉 2020-11-30 05:02

I am trying to write a method that makes a \"log.txt file\" if one does not already exist and then writes to the file. The problem that I am encountering is every time I cal

9条回答
  •  渐次进展
    2020-11-30 05:32

    Just change PrintWriter out = new PrintWriter(log); to

    PrintWriter out = new PrintWriter(new FileWriter(log, true));
    

提交回复
热议问题