小编Tim*_*thy的帖子

如何检查异常的类型以及它们的嵌套异常类型?

假设我捕获了一个类型异常AppException但我只想对该异常执行某些操作,如果它有类型的嵌套异常StreamException.

if (e instanceof AppException)
{
    // only handle exception if it contains a
    // nested exception of type 'StreamException'
Run Code Online (Sandbox Code Playgroud)

如何检查嵌套StreamException

java exception instanceof

19
推荐指数
2
解决办法
4万
查看次数

标签 统计

exception ×1

instanceof ×1

java ×1