在读取序列化对象时,我收到错误(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)