Here you can find the source of stackTraceToString(Throwable th)
public static final String stackTraceToString(Throwable th)
//package com.java2s; /*// ww w. j ava 2 s .c o m * Copyright (c) 2008-2011 by Jan Stender, Bjoern Kolbeck, * Zuse Institute Berlin * * Licensed under the BSD License, see LICENSE file for details. * */ import java.io.ByteArrayOutputStream; import java.io.PrintStream; public class Main { public static final String stackTraceToString(Throwable th) { PrintStream ps = null; try { ByteArrayOutputStream out = new ByteArrayOutputStream(); ps = new PrintStream(out); if (th != null) th.printStackTrace(ps); return new String(out.toByteArray()); } finally { if (ps != null) ps.close(); } } }