Java Stacktrace to String getStackTraceFromException(Exception _e)

Here you can find the source of getStackTraceFromException(Exception _e)

Description

Creates a String from the stack trace of an exception.

License

Apache License

Parameter

Parameter Description
_e the exception this method returns the stack trace of

Return

a String containing the complete stack trace of the passed exception

Declaration

public static String getStackTraceFromException(Exception _e) 

Method Source Code

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

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

public class Main {
    /**/*from  w  ww . ja va2s  .  c o m*/
     * Creates a String from the stack trace of an exception.
     * Usually used to construct a string that's passed to the logger.
     *
     * @param _e the exception this method returns the stack trace of
     *
     * @return a String containing the complete stack trace of the passed exception
     */
    public static String getStackTraceFromException(Exception _e) {
        StringWriter sw = new StringWriter();
        _e.printStackTrace(new PrintWriter(sw));
        return sw.toString();
    }
}

Related

  1. getStacktraceAsString(Exception e)
  2. getStacktraceAsString(Exception e)
  3. getStackTraceAsString(Exception e)
  4. getStackTraceAsString(Exception e)
  5. getStackTraceAsString(String pstrMessage, Exception poException)
  6. getStackTraceFromException(Exception e)
  7. getStackTraces()
  8. getStackTraceStr(Exception e)
  9. getStackTraceString()