在方法中加入以下代码:
Throwable throwable = new Throwable(); StackTraceElement[] stackElements = throwable.getStackTrace(); if (stackElements != null) { for (int i = 0; i < stackElements.length; i++) { System.out.print(stackElements[i].getClassName()+"/t"); System.out.print(stackElements[i].getFileName()+"/t"); System.out.print(stackElements[i].getLineNumber() + "/t"); System.out.println(stackElements[i].getMethodName()); System.out.println("---------------------------------------------------"); } }
时间: 2024-10-19 14:00:42