cn.hutool.core.io.IORuntimeException Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hutool-all Show documentation
Show all versions of hutool-all Show documentation
Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。
package cn.hutool.core.io;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.util.StrUtil;
/**
* IO运行时异常,常用于对IOException的包装
*
* @author xiaoleilu
*/
public class IORuntimeException extends RuntimeException {
private static final long serialVersionUID = 8247610319171014183L;
public IORuntimeException(Throwable e) {
super(ExceptionUtil.getMessage(e), e);
}
public IORuntimeException(String message) {
super(message);
}
public IORuntimeException(String messageTemplate, Object... params) {
super(StrUtil.format(messageTemplate, params));
}
public IORuntimeException(String message, Throwable throwable) {
super(message, throwable);
}
public IORuntimeException(Throwable throwable, String messageTemplate, Object... params) {
super(StrUtil.format(messageTemplate, params), throwable);
}
/**
* 导致这个异常的异常是否是指定类型的异常
*
* @param clazz 异常类
* @return 是否为指定类型异常
*/
public boolean causeInstanceOf(Class extends Throwable> clazz) {
final Throwable cause = this.getCause();
return null != clazz && clazz.isInstance(cause);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy