本帖最后由 空心祭 于 2014-4-2 21:12 编辑
public static void read()throws Exception
{
RandomAccessFile rf = new RandomAccessFile("ran.txt","r");
rf.seek(8);
byte[] bt = new byte[4];
rf.read(bt);
String name = new String(bt);
int age = rf.readInt();
System.out.println(name);
System.out.println("age="+age);
rf.close();
}
public static void write_1()throws Exception
{
RandomAccessFile rf = new RandomAccessFile("ran.txt","rw");
rf.write("李四".getBytes());
rf.writeInt(97);
rf.write("王五".getBytes());
rf.writeInt(99);
rf.close();
}
我在主函数内调用read方法的时候 出来的age的结果是538976355 不是99 这是为什么
|