java.io.EOFException尝试读取序列化对象时

时间:2013-05-08 13:23:27

标签: java exception inputstream fileinputstream

我将一个数据对象序列化到一个文件中,然后尝试将该对象读回到一个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();
    }

任何想法?

0 个答案:

没有答案