I have some java serialization code. It compiles and ran properly. But the resultant file is empty. Below is my code
The parameters are either arraylist of integers, arraylist of Strings or arraylist of arraylists of integers
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;
}
You’re not writing anything to any file. You are only reading from a file.
If you want to write to a file use an *Output*Stream.