序列化:读取序列化文件失败

时间:2017-06-20 19:44:21

标签: java deserialization objectinputstream gzipinputstream bytearrayinputstream

我的代码是:

try {             
                        // De-serialize it!
                        ByteArrayInputStream fis = new 
                        ByteArrayInputStream(serFile);
                        GZIPInputStream gzis = new GZIPInputStream(fis);
                        ObjectInputStream ois = new ObjectInputStream(gzis);                
                        reptDef = (AdHocReportDefinition)ois.readObject();                  


                    }

我在读取seralized文件时在ObjectInputStream上收到此错误。

 java.io.EOFException: Unexpected end of ZLIB input stream
        at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:234)
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:152)
        at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:101)
        at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2307)
        at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2320)
        at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2791)
        at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:795)
        at java.io.ObjectInputStream.<init>(ObjectInputStream.java:293)

0 个答案:

没有答案