反序列化.dat文件时出错

时间:2014-10-31 05:58:29

标签: java database excel serialization deserialization

我的老师向我提供了系列化的文件..我没有创建它自己..在取消文件后我得到以下错误

java.io.InvalidClassException: netflix.memreader.FeatureWriter; local class incompatible: stream classdesc serialVersionUID = 3279065858639389501, local class serialVersionUID = -7190666486441488760
    at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:562)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1583)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at netflix.memreader.FeatureWriter.deserialize(FeatureWriter.java:327)
    at netflix.memreader.MemReader.readFeaturesFromMem(MemReader.java:811)
    at netflix.memreader.MemReader.main(MemReader.java:727)
Exception in thread "main" java.lang.NullPointerException
    at netflix.memreader.MemReader.readFeaturesFromMem(MemReader.java:814)
    at netflix.memreader.MemReader.main(MemReader.java:727)

1 个答案:

答案 0 :(得分:0)

正如例外所说,

  

本地类不兼容:stream classdesc serialVersionUID,local   class serialVersionUID

序列化对象具有不同的serialVersionUID。当您尝试反序列化对象时,如果您没有指定默认值,则编译器将生成serialVersionUID

serialVersionUID可能因不同编译器(在各种平台上)的相同对象而异。你可以添加,

private static final long serialVersionUID = -7190666486441488760;