Java Throwable to String GetStacktrace(Throwable t)

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

Description

Get Stacktrace

License

Open Source License

Declaration

public static String GetStacktrace(Throwable t) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static String GetStacktrace(Throwable t) {
        final Writer result = new StringWriter();
        final PrintWriter printWriter = new PrintWriter(result);
        boolean first = true;
        Throwable tt = t;/*from   w ww  . ja v  a  2s  .  co  m*/
        do {
            if (!first) {
                printWriter.append("Caused by: ");
            }
            first = false;
            tt.printStackTrace(printWriter);
        } while ((tt = tt.getCause()) != null);
        return result.toString();
    }
}

Related

  1. getStackTrace(Throwable t)
  2. getStackTrace(Throwable t)
  3. getStackTrace(Throwable t)
  4. getStackTrace(Throwable t)
  5. getStackTrace(Throwable t)
  6. getStackTrace(Throwable t)
  7. getStackTrace(Throwable t)
  8. getStackTrace(Throwable t)
  9. getStackTrace(Throwable t)