0
DataOutputStream
當我拔出電纜時不會拋出IOException
,我的代碼出了什麼問題?Java DataOutputStream在斷開連接時不會拋出IOException
這裏是我的代碼:
private void sendMessage(String message) {
try {
mDataOutputStream.writeUTF(message);
mDataOutputStream.flush();
} catch(IOException ex) {
close();
}
}
當我插上電纜回,數據仍然發送到服務器。
你等了很久,看看它是否最終會超時? – NPE
是的,我已經等了超過一個小時的超時時間。 –