Java Throwable to String getStackTraceWithoutCause(Throwable throwable)

Here you can find the source of getStackTraceWithoutCause(Throwable throwable)

Description

get Stack Trace Without Cause

License

Open Source License

Declaration

public static String getStackTraceWithoutCause(Throwable throwable) 

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 getStackTraceWithoutCause(Throwable throwable) {
        String result = "";
        StackTraceElement[] trace = throwable.getStackTrace();
        result += throwable.getLocalizedMessage();
        for (StackTraceElement element : trace) {
            result += "\n at " + element;
        }//  ww w .  j  a  va  2  s  . c o m
        return result + "\n";
    }

    public static String getStackTrace(Throwable throwable) {
        Writer writer = new StringWriter();
        PrintWriter printWriter = new PrintWriter(writer);
        throwable.printStackTrace(printWriter);
        return writer.toString();
    }
}

Related

  1. getStackTraceString(Throwable e)
  2. getStackTraceString(Throwable t)
  3. getStackTraceString(Throwable throwable)
  4. getStackTraceString(Throwable throwable)
  5. getStackTraceString(Throwable tr)
  6. printStackTrace(Throwable t)
  7. serialize(Throwable t)
  8. serializeStackTrace(Throwable _t)
  9. serializeStackTrace(Throwable th)