小编use*_*582的帖子

Java中的序列化,无效的类型代码00

在读取序列化对象时,我收到错误(java.io.StreamCorruptedException:无效的类型代码:00).这是实现serializable的类:

package guts;

import cc.mallet.classify.*;
import java.io.*;


public class NaiveBayesWithID implements Serializable  {

private NaiveBayes nb;
private static final long serialVersionUID = 1;
    private static final int CURRENT_SERIAL_VERSION = 1;

public NaiveBayesWithID(NaiveBayes nb) {
this.nb = nb;
}
public NaiveBayesWithID(){
this.nb = null;
}

    public void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    int version = in.readInt();
    if (version != CURRENT_SERIAL_VERSION)
        throw new ClassNotFoundException("Mismatched NaiveBayesTrainer versions: wanted " +
                CURRENT_SERIAL_VERSION + ", got " +
                version);

    //default selections for the kind …
Run Code Online (Sandbox Code Playgroud)

java serialization

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×1

serialization ×1