int data[] = { 1, 2,3,4,5,6,7,8,9,10,11,12};
try {
RandomAccessFile randf = new RandomAccessFile("Fibonacci.dat", " rw");
for (int i = 0; i < data.length; i++)
randf.writeInt(data[i]);
System.out.println("以反序方式输出数列:");
for (int i = data.length - 1; i >= 0; i--) {
randf.seek( [1] ); // 移动读写指针(int数据占4个字节)
System.out.print(randf.readInt() + "\t");// 读取整数
}
randf.close();//关闭文件
} catch (IOException e) {
System.out.println("文件存取错误!" + e);
}
try {
RandomAccessFile randf = new RandomAccessFile("Fibonacci.dat", " rw");
for (int i = 0; i < data.length; i++)
randf.writeInt(data[i]);
System.out.println("以反序方式输出数列:");
for (int i = data.length - 1; i >= 0; i--) {
randf.seek( [1] ); // 移动读写指针(int数据占4个字节)
System.out.print(randf.readInt() + "\t");// 读取整数
}
randf.close();//关闭文件
} catch (IOException e) {
System.out.println("文件存取错误!" + e);
}