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();}

解决方案 »

  1.   

    用Append模式打开该文件,即:FileWriter fw = new FileWriter("hello.txt", true);  
      

  2.   

    。public void write(char[] cbuf,
                      int off,
                      int len)
               throws IOException写入字符数组的某一部分。 指定者:
    类 Writer 中的 write
    参数:
    cbuf - 字符缓冲区
    off - 开始写入字符处的偏移量
    len - 要写入的字符数 
    调整off的值不就可以了
      

  3.   

    FileWriter fw = new FileWriter("hello.txt",true);  
      

  4.   

    String s =  url+"(on page " + base + ")\n\r";