import java.io.*;
class Test
{
public static void main(String[] args)throws IOException
{
//ReadMy rw=new ReadMy();s
//rw.read();
WriterMy wm=new WriterMy();
wm.writer();
}
}
class ReadMy
{
public void read()throws IOException
{
RandomAccessFile raf=new RandomAccessFile("x.txt","rw");
raf.write("丽丽".getBytes());
raf.writeInt(97);
raf.close();
}
}
class WriterMy
{
public void writer()throws IOException
{
RandomAccessFile raf=new RandomAccessFile("x.txt","r");
byte[] b=new byte[1024];
raf.read(b);
String name=new String(b);
int age=raf.readInt();
System.out.println(name);
System.out.println(age);
raf.close();
}
}
//这个程序为什么编译通过,但运行不了。求解决。。。
|
|