Java Throwable to String stackTraceAsString(Throwable e)

Here you can find the source of stackTraceAsString(Throwable e)

Description

stack Trace As String

License

Open Source License

Declaration

public static String stackTraceAsString(Throwable e) 

Method Source Code

//package com.java2s;

import java.io.PrintWriter;

import java.io.StringWriter;

public class Main {
    public static String stackTraceAsString(Throwable e) {
        String stackAsString = "";
        if (e != null) {
            StringWriter writer = new StringWriter();
            PrintWriter pw = new PrintWriter(writer);
            e.printStackTrace(pw);/* w ww.  j  ava 2s .c om*/
            stackAsString = writer.toString();
        }
        return stackAsString;
    }
}

Related

  1. stackTrace(Throwable t)
  2. stackTrace(Throwable th)
  3. stackTrace(Throwable th, String pattern)
  4. stackTrace(Throwable throwable)
  5. stackTraceAsString(final Throwable aError)
  6. stackTraceAsString(Throwable throwable)
  7. stacktraceError(Throwable e)
  8. stackTraceFor(final Throwable exception)
  9. stackTraceFromException(Throwable ex)