ExceptionUtil
来源:互联网 发布:淘宝雪花代码在线生成 编辑:程序博客网 时间:2024/06/03 17:28
/**
* 获取异常的堆栈信息
*
* @author Administrator
*
*/
public class ExceptionUtils {
public static String getStackTrace(Throwable t) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
try {
t.printStackTrace(printWriter);
return writer.toString();
} finally {
printWriter.close();
}
}
public static void main(String[] args) {
Throwable t = new Throwable("错误信息展示");
String trace = ExceptionUtils.getStackTrace(t);
System.err.println(trace);
}
* 获取异常的堆栈信息
*
* @author Administrator
*
*/
public class ExceptionUtils {
public static String getStackTrace(Throwable t) {
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
try {
t.printStackTrace(printWriter);
return writer.toString();
} finally {
printWriter.close();
}
}
public static void main(String[] args) {
Throwable t = new Throwable("错误信息展示");
String trace = ExceptionUtils.getStackTrace(t);
System.err.println(trace);
}
}
测试结果
阅读全文
0 0
- ExceptionUtil
- ExceptionUtil
- ExceptionUtil
- ExceptionUtil:打印堆栈信息
- TensorFlow + Docker + PyCharm
- scp
- PCB新手养成日记
- 集合类Map ConcurrentHashMap Collections.synchronizedMap()
- 如何利用Open Live Writer发布CSDN博客
- ExceptionUtil
- Python3 BeautifulSoup pymysql
- NOIP C++ 生涯
- pythonGui 对话框
- facebook登录和分享
- LeetCode 125:Valid Palindrome(c++)
- 2017技术书单
- 【LeetCode】5. Longest Palindromic Substring
- 实现"输入框"获得焦点时外边框变蓝