看板 java 關於我們 聯絡資訊
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
yorjing:謝謝幫忙 似乎是dirty bit關係 看來直接傳byte[]沒這問題 06/25 17:46