这是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)
我做错了什么?