向文件尾部追加内容
//向文件尾部追加内容
public static void main( String [] args) throws FileNotFoundException,IOException { for (int i=0;i<100;i++){ appendContent("D:\\Q\\test\\testfile\\1.txt","这是第"+i); } } private static void appendContent(String filePath,String content) throws FileNotFoundException,IOException { RandomAccessFile randomAccessFile=new RandomAccessFile(filePath,"rw"); randomAccessFile.seek(randomAccessFile.length()); randomAccessFile.writeUTF(content+"\r\n"); randomAccessFile.close(); }