Java Stacktrace Print printStackTrace(Throwable e)

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

Description

print Stack Trace

License

Open Source License

Declaration

public static String printStackTrace(Throwable e) 

Method Source Code


//package com.java2s;

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

public class Main {

    public static String printStackTrace(Throwable e) {
        StringWriter stm = new StringWriter();
        PrintWriter wrt = new PrintWriter(stm);
        e.printStackTrace(wrt);//from www .  j a  va2s  .  c o m
        wrt.close();
        return stm.toString();
    }

    public static String toString(String[] content, String sign) {
        if (null == content) {
            return null;
        }

        sign = null == sign ? "," : sign;
        StringBuilder strBuilder = new StringBuilder();
        for (int i = 0; i < content.length; i++) {
            strBuilder.append(content[i]);
            if (i < content.length - 1) {
                strBuilder.append(sign);
            }
        }

        return strBuilder.toString();
    }
}

Related

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