我有类似的东西。
void func() {
try {
//socket disconnects in middle of ..parsing packet..
} catch(Exception ex) {
if(!ex.getMessage().toString().equals("timeout") || !ex.getMessage().toString().equals("Connection reset")) {
debug("Exception (run): " + ex.getMessage());
ex.printStackTrace();
}
}
为什么当我收到连接重置异常或超时异常时,它仍然在条件内。我试过没有 toString 也没有运气。