Here you can find the source of stackTraceToString(StackTraceElement[] stackTrace)
public static String stackTraceToString(StackTraceElement[] stackTrace)
//package com.java2s; //License from project: Open Source License public class Main { public static String stackTraceToString(StackTraceElement[] stackTrace) { StringBuilder sb = new StringBuilder(); for (StackTraceElement element : stackTrace) { sb.append(element.toString()).append(" (") .append(element.getLineNumber()).append(")"); sb.append("\n"); }/*from w w w. j av a 2s. co m*/ return sb.toString(); } public static String stackTraceToString(Throwable e) { return stackTraceToString(e.getStackTrace()); } }