日期:2014-05-20  浏览次数:20820 次

怎么修改使得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);