因项目需要,把clentAbortExctption的异常屏蔽掉,主要是这个异常无关紧要,处理方法:
try{
//省略
}catch (UnsupportedEncodingException e) {
String simplename = e.getClass().getSimpleName();
if(!"ClientAbortException".equals(simplename)){
e.printStackTrace();
}
} catch (IOException e) {
String simplename = e.getClass().getSimpleName();
if(!"ClientAbortException".equals(simplename)){
e.printStackTrace();
}
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
String simplename = e.getClass().getSimpleName();
if(!"ClientAbortException".equals(simplename)){
e.printStackTrace();
}
}
}
}
}
本文介绍了一种在Java中屏蔽特定ClientAbortException异常的方法。通过检查异常类型并仅在异常不是ClientAbortException的情况下打印堆栈跟踪,可以避免不重要的异常打断程序流程。
3万+

被折叠的 条评论
为什么被折叠?



