?? 例12.txt
字號:
import java.io.*;
public class Example
{
public static void main(String args[])
{
RandomAccessFile inAndOut=null;
int data[]={20,30,40,50,60};
try{
inAndOut=new RandomAccessFile("a.dat","rw");
}
catch(Exception e){}
try{
for(int i=0;i<data.length;i++)
{
inAndOut.writeInt(data[i]);
}
for(long i=data.length-1;i>=0;i--) //一個int型數(shù)據(jù)占4個字節(jié),我們從
{ //文件的第36個字節(jié)讀取最后面的一個整數(shù),
inAndOut.seek(i*4); //每隔4個字節(jié)往前讀取一個整數(shù).
System.out.printf("\t%d",inAndOut.readInt());
}
inAndOut.close();
}
catch(IOException e){}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -