堆栈的超链接

阅读更多

try {
throw new Exception();
} catch (Exception e) {
// TODO: handle exception
StackTraceElement[] stackTrace = e.getStackTrace();
for (int i = 0; i < stackTrace.length; i++) {
StackTraceElement stackTraceElement = stackTrace[i];
StringBuffer sb = new StringBuffer();
sb.append("/n");
sb.append(stackTraceElement.getClassName());
sb.append(".");
sb.append(stackTraceElement.getMethodName());
sb.append("(" + stackTraceElement.getFileName() + ":" + stackTraceElement.getLineNumber() + ")" );
System.out.println(sb.toString());
}
}

 

粗体字部分即超链接功能。

你可能感兴趣的:(java)