Here you can find the source of stackTrace(StackTraceElement[] stackTrace)
public static String stackTrace(StackTraceElement[] stackTrace)
//package com.java2s; //License from project: Apache License public class Main { public static String stackTrace(StackTraceElement[] stackTrace) { StringBuilder str = new StringBuilder(""); for (StackTraceElement s : stackTrace) { str.append("\t").append(s.getClassName() + "." + s.getMethodName() + "(" + s.getFileName() + ":" + s.getLineNumber() + ")" + "\n"); }/*from ww w . java2 s .c om*/ return str.toString(); } public static String stackTrace(String msg, Throwable throwable) { StringBuilder str = new StringBuilder(throwable.getMessage() + " : " + msg + "\n"); str.append(stackTrace(throwable.getStackTrace())); return str.toString(); } }