//https://www.cnblogs.com/elleniou/archive/2012/08/29/2662353.html //不能循环写入否则修改源码 /* for (Student student1 : arr) { oos.writeObject(student1); }*/
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("list.txt")); //ArrayList<Student> list = (ArrayList<Student>)ois.readObject(); Student list = (Student)ois.readObject(); /* for (int i = 0; i < list.size(); i++ ){ Student s = list.get(i); System.out.println(s); }*/ System.out.println(list);