Here you can find the source of getStackTraceWithoutCause(Throwable throwable)
public static String getStackTraceWithoutCause(Throwable throwable)
//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(); } }