Here you can find the source of printStackTrace(PrintStream out)
public static final void printStackTrace(PrintStream out)
//package com.java2s; //License from project: Open Source License import java.io.PrintStream; public class Main { public static final void printStackTrace(PrintStream out) { StringBuilder sb = new StringBuilder(); sb.append("Printing Stack Trace\n"); for (StackTraceElement ste : Thread.currentThread().getStackTrace()) { sb.append('\t'); sb.append(ste);/*from w w w. j av a2 s. co m*/ sb.append('\n'); } out.print(sb); } public static final void printStackTrace() { printStackTrace(System.err); } }