我想在 android 手机上编写一个客户端并将一个对象发送到在我的 windows PC 上运行的服务器(使用 ObjectDecoderInputStream ),但是有这些异常
例外
java.io.StreamCorruptedException: unexpected end of block data
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.access$300(Unknown Source)
at java.io.ObjectInputStream$GetFieldImpl.readFields(Unknown Source)
at java.io.ObjectInputStream.readFields(Unknown Source)
at java.net.InetSocketAddress.readObject(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeReadObject(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at org.jboss.netty.handler.codec.serialization.ObjectDecoderInputStream.readObject(ObjectDecoderInputStream.java:115)
at MainActivity.main(MainActivity.java:30)
但是当我在手机上使用 CompatibleObjectEncoder/Decoder 并在 PC 上使用 ObjectInputStream 时,它工作正常。如果我将 android 代码更改为 Java 代码,并在我的 PC 上运行客户端以使用 ObjectEncoder 及其相关的 InputStream 向我自己发送对象,它工作正常。
顺便说一句,我使用netty 3.6.3 final,我的android设备是2.3.7姜饼(使用jre 1.5或1.6),我的PC是jre 1.7,这可能有问题吗?