seek()的用法问题!
class RandomFile {public RandomFile() {
}
void n(){
int [] A = {1,2,3,4,5,6,7,8,9,0};
try{
RandomAccessFile obj= new RandomAccessFile("rand.dat","rw");
for (int i=0;i<A.length;i++){
obj.writeInt(A[i]);
}
System.out.println("逆向内容");
for(int i=A.length-1;i>=0;i--){
obj.seek(i*4);
System.out.println(obj.readInt());
} obj.close();
}catch (Exception n){
System.out.println("发生异常"+n);
}finally {
System.out.println("始终在最后执行...");
System.out.println("在 finally 语句块内");
}
}
public static void main(String[] args) {
RandomFile randomfile = new RandomFile();
randomfile.n();
}
}
请问seek()里为什么要乘以4才可以?
seek()的用法?
[[it] 本帖最后由 d460548216 于 2008-10-7 14:04 编辑 [/it]]