Here you can find the source of displayStackTrace()
public static String displayStackTrace()
//package com.java2s; //License from project: Open Source License import java.util.Formatter; public class Main { public static String displayStackTrace() { return displayStackTrace(null); }/*ww w . jav a 2 s.c om*/ public static String displayStackTrace(StackTraceElement[] stack) { StringBuilder sb = new StringBuilder(256); Formatter f = new Formatter(sb); if (stack == null) stack = Thread.currentThread().getStackTrace(); sb.append("stack trace:\n"); for (StackTraceElement ste : stack) { String[] classInfo = ste.getClassName().split("\\.", -1); sb.append("\t"); sb.append(classInfo[classInfo.length - 1]); sb.append("."); sb.append(ste.getMethodName()); sb.append(" ("); sb.append(ste.getClassName()); sb.append(".java"); // sb.append(ste.getFileName()); sb.append(":"); sb.append(ste.getLineNumber()); sb.append(")\n"); } String rv = sb.toString(); f.close(); return sb.toString(); } }