我将一个数据对象序列化到一个文件中,并尝试将该对象读回到一个servelet中。我遇到了异常
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
我的代码是
FileInputStream fin;
try
{
fin = new FileInputStream( "G:\\search\\webapp\\DataManager\\WSList" );
ObjectInputStream ois = new ObjectInputStream( fin );
InfoRpc newObj = ( InfoRpc ) ois.readObject();
newObj.getCategories();
ois.close();
return newObj;
}
catch ( FileNotFoundException e )
{
e.printStackTrace();
}
catch ( IOException e )
{
e.printStackTrace();
}
catch ( ClassNotFoundException e )
{
e.printStackTrace();
}
任何想法 ?