Here you can find the source of stackTraceString(final Throwable exception)
public static String stackTraceString(final Throwable exception)
//package com.java2s; /*-/*from w w w . j a v a 2 s . c o m*/ * See the file LICENSE for redistribution information. * * Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved. * */ import java.io.ByteArrayOutputStream; import java.io.PrintStream; public class Main { public static String stackTraceString(final Throwable exception) { ByteArrayOutputStream bao = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(bao); exception.printStackTrace(printStream); String stackTraceString = bao.toString(); return stackTraceString; } }