FileOutputStream(File file, boolean append)// append=true追加写 append=false覆盖写

解决方案 »

  1.   

    writeMethod方法中,做如下修改
    修改前:FileOutputStream fos = new FileOutputStream("student.txt");
    修改后:FileOutputStream fos = new FileOutputStream("student.txt", true);第二个参数如果为true,则默认在写文件的时候是在末尾追加而不是重新写文件,
    还有ObjectOutputStream在写操作后,记得关闭流。
         oos.close();
      

  2.   

    谢谢!还有我往文件里面写完很多个student类以后, 我想读取某个 名字或 学号ID的 学生类信息。怎么读?指针代码怎么写?