公众号:架构师与哈苏
关注公众号进入it交流群! 公众号:架构师与哈苏 不定时都会推送一些实用的干货。。。
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());
posted on 2021-08-04 14:14  公众号/架构师与哈苏  阅读(112)  评论(0编辑  收藏  举报