Java Stacktrace to String getStackTraceAsString(Exception e)

Here you can find the source of getStackTraceAsString(Exception e)

Description

get Stack Trace As String

License

Open Source License

Declaration

public static String getStackTraceAsString(Exception e) 

Method Source Code

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

public class Main {
    public static String getStackTraceAsString(Exception e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw, true);
        e.printStackTrace(pw);//from  w  w  w  .  j  a va2s . c  o m
        pw.flush();
        sw.flush();
        String rv = sw.toString();
        String[] s = rv.split("\\n", 65);
        if (s.length < 65)
            return rv;
        rv = "";
        for (int i = 0; i < 64; i++)
            rv += s[i] + "\n";
        return rv;
    }
}

Related

  1. getStackTrace(Exception e)
  2. getStackTrace(Exception exception)
  3. getStackTrace(Exception x)
  4. getStacktraceAsString(Exception e)
  5. getStackTraceAsString(Exception e)
  6. getStacktraceAsString(Exception e)
  7. getStackTraceAsString(String pstrMessage, Exception poException)
  8. getStackTraceFromException(Exception _e)
  9. getStackTraceFromException(Exception e)