Here you can find the source of getExceptionStackTrace(Throwable exception)
public static String getExceptionStackTrace(Throwable exception)
//package com.java2s; /*/* ww w.ja va 2s.c o m*/ * Copyright 2001-2013 Geert Bevin (gbevin[remove] at uwyn dot com) * Licensed under the Apache License, Version 2.0 (the "License") */ import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String getExceptionStackTrace(Throwable exception) { if (null == exception) throw new IllegalArgumentException("exception can't be null;"); String stack_trace; StringWriter string_writer = new StringWriter(); try (PrintWriter print_writer = new PrintWriter(string_writer)) { exception.printStackTrace(print_writer); stack_trace = string_writer.getBuffer().toString(); } return stack_trace; } }