0
我在做一个hang子手游戏,目标是保存不同玩家的属性,比如他们的名字,玩过的游戏和胜利。我有这部分工作,但每次运行该程序它删除以前的数据并将其替换。Java PrintWriter:随着时间的推移写入相同的文件
public static void writeStats(File file,String name, int won, int games) {
try {
PrintWriter pw = new PrintWriter(file);
pw.println("Player\tWon\tTotal");
pw.println("-----------------------------");
pw.println(name+"\t"+won+"\t"+games);
pw.close();
} //end try
catch (IOException e) {
System.out.println("Failed to write file!");
} //end catch
} //end method
[如何将文本追加到Java中的现有文件](http://stackoverflow.com/questions/1625234/how-to-append-text-to-an-existing-file-in-java) – Tom