File Writer overrides previous write Java

前端 未结 2 661
遥遥无期
遥遥无期 2021-01-23 10:22
try {
                File file = new File(filePath+\"usedcommands.txt\");
                if (!file.exists()) {
                    file.createNewFile();
                       


        
2条回答
  •  不思量自难忘°
    2021-01-23 11:01

    Pass true as a second argument to FileWriter to turn on "append" mode.

    FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);
    

提交回复
热议问题