Java Throwable to String getStackTrace(Throwable exception)

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

Description

get Stack Trace

License

Open Source License

Declaration

public static String getStackTrace(Throwable exception) 

Method Source Code


//package com.java2s;
import java.io.PrintWriter;
import java.io.StringWriter;

public class Main {

    public static String getStackTrace(Throwable exception) {
        StringWriter sw = null;//from www  .  ja v a  2 s  .co  m
        PrintWriter pw = null;
        try {
            sw = new StringWriter();
            pw = new PrintWriter(sw);
            exception.printStackTrace(pw);
            return sw.toString();
        } finally {
            if (pw != null) {
                pw.close();
            }
        }
    }
}

Related

  1. getStackTrace(Throwable e)
  2. getStackTrace(Throwable ex)
  3. getStackTrace(Throwable ex)
  4. getStackTrace(Throwable ex)
  5. getStackTrace(Throwable exc)
  6. getStackTrace(Throwable exception)
  7. getStackTrace(Throwable pException)
  8. getStackTrace(Throwable pThrowable_)
  9. getStackTrace(Throwable t)