java.io.invalidClassException during serializing/deserializing

后端 未结 3 1799
再見小時候
再見小時候 2020-12-07 02:45

I\'ve got an object that im reading and writing to and from fileinputstreams/objectinputstreams and objectinputstreams/objectoutputstreams. I keep

3条回答
  •  青春惊慌失措
    2020-12-07 03:05

    Are you reading from a file? In that case, it does not matter if you added the serialVersionUID now, it is different from the one stored in the file, and that creates the exception.

    A quick solution could be to set serialVersionUID to 4209360273818925922L, which seems to be the serialVersionUID that was automatically generated by java when you saved those object in that file at that time :)

提交回复
热议问题