package com.guo.httptest.fun;
import java.io.IOException;
import java.io.RandomAccessFile;
public class Test2 {
public static void main(String[] args) throws IOException {
for (int i = 0; i < 10; i++) {
RandomAccessFile rf = new RandomAccessFile("C://temp//number.txt","rws"); //"r", "rw", "rws", or "rwd"
rf.seek(rf.length());
rf.writeBytes(i+"/r/n");
rf.close();
}
}
}
打开C盘下temp文件夹下的number.txt(生成的文件)会看到如下结果