Here you can find the source of getStackTraceString(Exception e)
Exception
's stack trace to a String
.
public static String getStackTraceString(Exception e)
//package com.java2s; /*/*from w w w . j a v a 2 s . c om*/ * $RCSfile: ImageUtil.java,v $ * * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.2 $ * $Date: 2006/07/21 20:53:28 $ * $State: Exp $ */ import java.io.ByteArrayOutputStream; import java.io.PrintStream; public class Main { /** * Converts the supplied <code>Exception</code>'s stack trace * to a <code>String</code>. */ public static String getStackTraceString(Exception e) { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(byteStream); e.printStackTrace(printStream); printStream.flush(); String stackTraceString = byteStream.toString(); printStream.close(); return stackTraceString; } }