java.io.StreamCorruptedException:无效的流标头?

时间:2012-02-21 16:46:53

标签: java

这是Alternative to com.google.common.io.ByteArrayDataInput?

的延续

我正在尝试运行以下代码:

public String convertToXml(final byte[] binary) {
        ByteArrayInputStream bais = new ByteArrayInputStream(binary);
        BufferedInputStream bis = new BufferedInputStream(bais);
        ObjectInputStream ois = null; 
        try {
            ois = new ObjectInputStream(bis);
        } catch (IOException e1) {
            throw new ConversionException("Unable to instantiate ObjectInputStream", e1);
        }
     // ...
}

但我一直在接受:

Caused by: java.io.StreamCorruptedException: invalid stream header: 1278D4DB
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:782)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)

我做错了什么?

0 个答案:

没有答案