package hanjia;
import java.io.*;
class hanjia{
public static void main(String args[]) throws IOException {
try {
RandomAccessFile raf = new RandomAccessFile("f:/char1.dat", "rw");
for (int i = 0; i < 10; i++)
raf.writeInt(i * i);
System.out.println("处于偶数位置的序列: ");
long length = raf.length();
for (int i = 4; i < length; i += 2 * 4) {
raf.seek(i);
System.out.print(raf.readInt() + " ");
}
raf.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200501120959614.png)