Here you can find the source of stacktrace2string(StackTraceElement[] stackTraceElements)
public static String stacktrace2string(StackTraceElement[] stackTraceElements)
//package com.java2s; //License from project: Open Source License import java.io.PrintWriter; import java.io.StringWriter; import java.io.Writer; public class Main { public static String stacktrace2string(StackTraceElement[] stackTraceElements) { StringBuffer stackTraceStringBuffer = new StringBuffer(); for (StackTraceElement stackTraceElement : stackTraceElements) { stackTraceStringBuffer.append(stackTraceElement.toString()).append("\n"); }//from www . j a va2s . c o m return stackTraceStringBuffer.toString(); } public static String stacktrace2string(Throwable x) { final Writer result = new StringWriter(); final PrintWriter printWriter = new PrintWriter(result); x.printStackTrace(printWriter); return result.toString(); } }