当前位置: 代码迷 >> Java相关 >> 如何修改使得Java写txt不覆盖呢
  详细解决方案

如何修改使得Java写txt不覆盖呢

热度:9319   发布时间:2013-02-25 21:46:03.0
怎么修改使得Java写txt不覆盖呢
Java code
try{              FileWriter fw = new FileWriter("hello.txt");                  String s =  url+"(on page " + base + ")\n";        fw.write(s,0,s.length());       fw.flush();      }     catch(Exception e)     {e.printStackTrace();}


------解决方案--------------------------------------------------------
用Append模式打开该文件,即:

FileWriter fw = new FileWriter("hello.txt", true);
  相关解决方案