Here you can find the source of printStackTrace(Throwable exception)
Parameter | Description |
---|---|
exception | a parameter |
public static String printStackTrace(Throwable exception)
//package com.java2s; //License from project: Apache License import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static String printStackTrace(Throwable exception) { if (exception == null) { return ""; } else {//from w ww. j a va 2 s . c om StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); exception.printStackTrace(pw); pw.flush(); String expString = sw.toString(); pw.close(); return expString; } } }