Java Stacktrace Print printStackTrace(Throwable exception)

Here you can find the source of printStackTrace(Throwable exception)

Description

print Stack Trace

License

Apache License

Parameter

Parameter Description
exception a parameter

Return

String

Declaration

public static String printStackTrace(Throwable exception) 

Method Source Code


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

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

public class Main {

    public static String printStackTrace(Throwable exception) {
        if (exception == null) {
            return "";
        } else {//from   w  ww.  j a  va 2  s .  c om
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            exception.printStackTrace(pw);
            pw.flush();
            String expString = sw.toString();
            pw.close();
            return expString;
        }
    }
}

Related

  1. printStackTrace(String header, int depth)
  2. printStackTrace(String msg, StackTraceElement[] trace, PrintStream out)
  3. printStackTrace(String msg, Throwable throwable)
  4. printStacktrace(Throwable aException)
  5. printStackTrace(Throwable e)
  6. printStackTrace(Throwable t)
  7. printStackTrace(Throwable t)
  8. printStackTrace(Throwable t)
  9. printStackTrace(Throwable throwable)