public static void main(String[] args) {
try {
FileInputStream fis = new FileInputStream("d:/per.tmp");
ObjectInputStream ios=new ObjectInputStream(fis);
Object obj=ios.readObject();
ios.close();
if(obj instanceof Person){
Person p=(Person) obj;
//System.out.println(p.getName()+","+p.getAge());
System.out.println(p);
}//java用序列化UID判断是否改过对象的代码
} catch (Exception e) {
e.printStackTrace();
}
}
java.io.InvalidClassException: com.itcast.day1.io.Person; local class incompatible: stream classdesc serialVersionUID = -2998053340727797937, local class serialVersionUID = 3661124393467516798 |
|