File file = new File("D:\\softTemp\\student.out");
ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream(file));
Student student = new Student("老吴",18);
objectOutputStream.writeObject(student);
objectOutputStream.close();
ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(file));
student = (Student) objectInputStream.readObject();
objectInputStream.close();
System.out.println(student.toString());