111.txt文件夹中的内容为: 1234
这个想不通,大家运行后,会发现 1234 变成了1233 也就是说多移了一位,但是如果 raf2.seek(raf2.length() -1)的话变成了 1234444 搞不懂啊,请教大家
import java.io.*;public class MyTest {
public static void main(String[] args)throws IOException{

RandomAccessFile raf2 = new RandomAccessFile(
new File("D:\\111.txt"),"rw");
raf2.seek(0);
for(int i = 0; i< 3; i++){
raf2.seek(raf2.length() -2);
raf2.write(raf2.read());
}
raf2.close();
}
}