将异常(getStackTrace)转化成String
程序员文章站
2022-03-31 09:35:50
...
private static String getStackMsg(Exception e) {
StringBuffer sb = new StringBuffer();
StackTraceElement[] stackArray = e.getStackTrace();
for (int i = 0; i < stackArray.length; i++) {
StackTraceElement element = stackArray[i];
sb.append(element.toString() + "\n");
}
return sb.toString();
}
private static String getStackMsg(Throwable e) {
StringBuffer sb = new StringBuffer();
StackTraceElement[] stackArray = e.getStackTrace();
for (int i = 0; i < stackArray.length; i++) {
StackTraceElement element = stackArray[i];
sb.append(element.toString() + "\n");
}
return sb.toString();
}
下一篇: 无边框 winForm 窗体的鼠标拖动