Java examples for java.lang:Throwable
show Call Stack via StackTraceElement
//package com.java2s; public class Main { public static void showCallStack() { StackTraceElement[] stackTraceElements = Thread.currentThread() .getStackTrace();/*ww w . j ava2 s.c o m*/ System.out .println("##############################################"); for (int i = 2; i < stackTraceElements.length; i++) { StackTraceElement ste = stackTraceElements[i]; String classname = ste.getClassName(); String methodName = ste.getMethodName(); int lineNumber = ste.getLineNumber(); System.out.println(classname + "." + methodName + ":" + lineNumber); } } }