错误结果:
2/07/11 9:01:25:CST PoolManager:connected
02/07/11 9:01:30:CST PoolManager:connected
002/07/11 9:01:32:CST PoolManager:connected
2002/07/11 9:01:35:CST PoolManager:connected
希望结果
2002/07/11 9:01:25:CST PoolManager:connected
2002/07/11 9:01:30:CST PoolManager:connected
2002/07/11 9:01:32:CST PoolManager:connected
2002/07/11 9:01:35:CST PoolManager:connected

解决方案 »

  1.   

    是有点问题啊!真是不好意思!I will try it! wait for a moment
      

  2.   

    有点问题啊!真是不好意思!I will try it! wait for a moment
      

  3.   

    是readline()出的问题。我发现第一个字符总是读不出来。现在还没找到问题原因,不过我觉得会有其它办法的。其它的语言比如vb可以把新的数据添加到已有文件里,在java里也应该有类似的方法吧。
      

  4.   

    Java里确实有append的方法,下面的代码是我写的,已经编译通过。import java.io.*;public class FileAppend{ FileOutputStream fos;
    String fn = "app.log"; public static void main(String[] args) {

    FileAppend file = new FileAppend(); // Create a new file if specified file does't exist.
    if (file.createFile(file.fn) == -1){
    return;
    };

    // Append a string to the file.
    file.appendToFile("\r\n01234567889");
    } public int createFile(String fn) { File file = new File(fn);

    if (!file.exists()) {
    try{
    file.createNewFile();
    }
    catch (IOException e){
    return -1;
    }
    } return 0; } public int appendToFile(String appendline){
    byte[] appendchr; if (fos == null) {
    try{
    fos = new FileOutputStream(fn, true);
    }
    catch (FileNotFoundException e) {
    return -1;
    }

    } appendchr = appendline.getBytes(); try{
    fos.write(appendchr);
    }
    catch (IOException e){
    return -1;
    } return 0;
    }
    }
      

  5.   

    添加功能实现的关键是函数appendToFile()中的
        fos = new FileOutputStream(fn, true);
    这行代码。其中的第二个参数表示以“添加”的形式写文件。
      

  6.   

    _No1_(天王盖地虎) 的办法应该是没问题,但是我还是想知道Computer_lover (水中鱼) 原来的程序错误如何解决!还希望各位出手!
      

  7.   

    还有一个问题:new FileOutputStream(Fiel, true)是jdk1.4的构建器,在jdk以前的版本无法用