怎样在原来文件的基础上写入文件,比如说:A.txt中本来有, abcdef,现在要加入ghi,变成,abcdefghi
应该怎么做.

解决方案 »

  1.   

    try {
            File f = new File("filename");
            RandomAccessFile raf = new RandomAccessFile(f, "rw");
        
            // Read a character
            char ch = raf.readChar();
        
            // Seek to end of file
            raf.seek(f.length());
        
            // Append to the end
            raf.writeChars("aString");
            raf.close();
        } catch (IOException e) {
        }