作者superlubu (叔叔你人真好)
看板java
标题Re: [问题] OptionalDataException
时间Wed Jun 25 13:30:33 2008
public class OptionalDataException
extends ObjectStreamException
Exception indicating the failure of an object read operation due to unread
primitive data, or the end of data belonging to a serialized object in the
stream. This exception may be thrown in two cases:
* An attempt was made to read an object when the next element in the
stream is primitive data. In this case, the OptionalDataException's
length field is set to the number of bytes of primitive data
immediately readable from the stream, and the eof field is set to false.
* An attempt was made to read past the end of data consumable by a
class-defined readObject or readExternal method. In this case, the
OptionalDataException's eof field is set to true, and the length
field is set to 0.
所以, catch 那个 OptionalDataException 下来再把它的 length 和 eof field
印出来看看是哪一个 case.
※ 引述《yorjing (问题儿童)》之铭言:
: 请问一下
: 有人碰过这个exception吗?
: 小弟刚刚写网路程式
: 碰到OptionalDataException
: 我是用ObjectInputStraem
: 把input.readObject转型成String物件
: =>String text=(String)input.readObject();
: 上面的input是ObjectInputStream的object
: 刚开始程式还没有什麽问题
: 结果程式跑一跑
: 就跑出这个例外...
: 我是用两台电脑测试的
: 一台还没有这个问题....
: 即使小弟用input.readObject() instanceof String去判断
: 可是还是会出现这个例外
: 请问各位大大
: 要怎样才能解决这个问题呢?
: 小弟先谢谢各位大大的帮忙
--
劲过吕布的劲过相簿...
http://www.pixnet.net/superlubu
乱七八糟的,不好意思 m(_ _)m
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 147.8.127.102
1F:推 yorjing:谢谢帮忙 似乎是dirty bit关系 看来直接传byte[]没这问题 06/25 17:46