Here you can find the source of getStackTrace(final Throwable t)
public static String getStackTrace(final Throwable t)
//package com.java2s; /*/*w ww.j a va 2 s . co m*/ * JBoss, Home of Professional Open Source. * * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing. * * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors. */ import java.io.ByteArrayOutputStream; import java.io.PrintWriter; public class Main { public static String getStackTrace(final Throwable t) { final ByteArrayOutputStream bas = new ByteArrayOutputStream(); final PrintWriter pw = new PrintWriter(bas); t.printStackTrace(pw); pw.close(); return bas.toString(); } /** * Return a stringified version of the array. * * @param array the array * @param delim the delimiter to use between array components * @return the string form of the array */ public static String toString(final Object[] array, final String delim) { if (array == null) { return ""; //$NON-NLS-1$ } if (array.length == 0) { return "[]"; //$NON-NLS-1$ } final StringBuffer sb = new StringBuffer(); sb.append('['); for (int i = 0; i < array.length; ++i) { if (i != 0) { sb.append(delim); } sb.append(array[i]); } sb.append(']'); return sb.toString(); } /** * Return a stringified version of the array, using a ',' as a delimiter * * @param array the array * @return the string form of the array * @see #toString(Object[], String) */ public static String toString(final Object[] array) { return toString(array, ","); //$NON-NLS-1$ } }