Here you can find the source of getStackTrace(final Throwable t)
public static String getStackTrace(final Throwable t)
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; public class Main { /** Extracts the given exception's corresponding stack trace to a string. */ public static String getStackTrace(final Throwable t) { try {//from ww w .j a v a2s . c om final ByteArrayOutputStream out = new ByteArrayOutputStream(); t.printStackTrace(new PrintStream(out, false, "UTF-8")); return new String(out.toByteArray(), "UTF-8"); } catch (final IOException exc) { return null; } } }