【发布时间】:2012-10-13 13:15:15
【问题描述】:
我有一些 java 序列化代码。它编译并正常运行。但生成的文件是空的。下面是我的代码
参数可以是整数数组列表、字符串数组列表或整数数组列表数组列表
Model model = new Model(
pennTreeTags,
tagsCount,
iOccurTable,
fOccurTable,
alVocab,
aiVocabCount,
wordTagTable,
fWordTagProb
);
try
{
FileInputStream fileIn = new FileInputStream(argv[2]);
ObjectInputStream in = new ObjectInputStream(fileIn);
model = (Model) in.readObject();
in.close();
fileIn.close();
}
catch (EOFException ex)
{
//This exception will be caught when EOF is reached
System.out.println("End of file reached.");
}
catch(IOException i)
{
i.printStackTrace();
return;
}
catch(ClassNotFoundException c)
{
System.out.println("Model class not found");
c.printStackTrace();
return;
}
【问题讨论】:
-
你发错代码了吗?这里没有发生序列化 - 这看起来像是从文件中反序列化?
-
当您编写此代码时,您是否只是决定将自己锁在一个无法访问 Internet 且没有可供参考的 Java 文档或书籍的房间中?
标签: java serialization arraylist