Here you can find the source of stackTrace()
public static String stackTrace()
//package com.java2s; //License from project: Apache License public class Main { public static String stackTrace() { StackTraceElement[] elements = Thread.currentThread().getStackTrace(); StringBuilder buf = new StringBuilder(); for (StackTraceElement element : elements) { buf.append("\r\n ").append(element.getClassName()).append(".").append(element.getMethodName()) .append("(").append(element.getFileName()).append(":").append(element.getLineNumber()) .append(")"); }//from w w w . j a v a 2 s .com return buf.toString(); } }