Java Stacktrace Print formatStackTrace(Throwable t)

Here you can find the source of formatStackTrace(Throwable t)

Description

format Stack Trace

License

Open Source License

Declaration

public static String formatStackTrace(Throwable t) 

Method Source Code


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

public class Main {
    public static String formatStackTrace(Throwable t) {
        StringWriter sw = new StringWriter();
        try {// w w w .j  a  v a 2  s . c om
            PrintWriter p = new PrintWriter(sw);
            t.printStackTrace(p);
        } catch (Exception e) {
        }
        return sw.toString();
    }
}

Related

  1. formatStackTrace(Thread thread)
  2. formatStackTrace(Throwable t)
  3. formatStackTrace(Throwable t, String prefix)
  4. formatStackTraceToString(Exception ex)
  5. printStackTrace()