序列化 :Serialization 将对象的状态信息转换为可以存储或传输的形式的过程。对象(内存)------->字节数组 字节序列(外存、网络)
反序列化:DeSerialization
字节数组 字节序列(外存、网络)----------->对象(内存)
存储或传输 比如存储到外存(硬盘)中 传输到网络
相应的类要实现Serializable接口
public class Student implements Serializable { }
ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(new Student(1, "111", 22, 333.3)); ObjectInputStream ois = new ObjectInputStream(bis); Student stu = (Student)ois.readObject(); |
(查看ObjectOutputStream源码)
com.bjsxt.entity.Student; local class incompatible:
stream classdesc serialVersionUID = 5954363181006202290,
local class serialVersionUID = -1877375566195009060
解决方案:给出一个固定的序列化版本号
原文:https://www.cnblogs.com/vincentmax/p/14245767.html