
可以把java的对象写到本地文件中

Student s = new Student("zhangsan",18);//学生类要给个接口(implements Serializable),使类可以序列化(相当于标签)
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStraem("..\\IOstream"));
oos.writeObject(stu);
oos.close();//相当与游戏存档
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("..\\IOstream\\"));
sout.ois.readobject();
ois.close();
相当于加密与解密
如果类需要修改,则要添加以下语句添加版本号
![]()

1771

被折叠的 条评论
为什么被折叠?



