Java Throwable to String stackTraceFromException(Throwable ex)

Here you can find the source of stackTraceFromException(Throwable ex)

Description

stack Trace From Exception

License

Apache License

Declaration

public static String stackTraceFromException(Throwable ex) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.PrintWriter;
import java.io.StringWriter;

public class Main {
    private static String EMPTY = "";

    public static String stackTraceFromException(Throwable ex) {
        if (null == ex) {
            return EMPTY;
        }/*from   w  ww . ja  va  2 s .  co m*/

        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);

        ex.printStackTrace(pw);

        return sw.toString();
    }
}

Related

  1. stackTraceAsString(final Throwable aError)
  2. stackTraceAsString(Throwable e)
  3. stackTraceAsString(Throwable throwable)
  4. stacktraceError(Throwable e)
  5. stackTraceFor(final Throwable exception)
  6. stackTraceFromThrowable(Throwable throwable)
  7. stackTraceOf(Throwable e)
  8. stackTraceString(final Throwable exception)
  9. stackTraceToCharSequence( final Throwable error)