import java.io.*;
class RandomAccessFile1
{
public static void main(String[] args) throws IOException
{
//write();
read();
//RandomAccessFile raf = new RandomAccessFile("Ryan1.txt","r"); //只读模式下无文件会出现异常
}
public static void read() throws IOException
{
RandomAccessFile raf = new RandomAccessFile("Ryan.txt","r");
//raf.seek(8*1); //指针要先于文件读取设置
raf.skipBytes(8); //跳过指定的字节数,这能向后跳,不能向前
byte[] buf = new byte[4];
raf.read(buf);
String name = new String(buf);
int age = raf.readInt();
sop("name:"+name);
sop("age="+age);
raf.close();
}