Source Code : Get stack trace and cause exception
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Get stack trace and cause exception
import java.io.PrintWriter;
import java.io.StringWriter;
public class ExceptionUtils {
public static String getStackTrace(Throwable e) {
StringWriter out = new StringWriter();
PrintWriter w = new PrintWriter(out);
e.printStackTrace(w);
w.flush();
return out.toString();
}
public static Throwable getCauseException(Exception e) {
if (e == null) return null;
Throwable cause = e.getCause();
if (cause != null) return cause;
else return e;
}
}
Thank with us