62,621
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) throws IOException
{
File f = new File("e:/Student1.txt");
Student[] s = new Student[3];
s[0] = new Student(18);
s[1] = new Student(19);
// Student s3 = new Student(20, "Jane");
RandomAccessFile raf = new RandomAccessFile(f, "rw");
for (int i = 0; i < 2; i++)
{
s[i].writeStudent(raf);
}
raf.close();
RandomAccessFile raf01 = new RandomAccessFile(f, "rw");
for (int i = 0; i < 2; i++)
{
Student stu = s[i].readStu(raf01);
System.out.println(stu);
}
raf01.close();
}