Throwable.printStackTrace(PrintWriter s) has the following syntax.
public void printStackTrace(PrintWriter s)
In the following code shows how to use Throwable.printStackTrace(PrintWriter s) method.
import java.io.FileNotFoundException; import java.io.PrintWriter; /* w ww. ja va 2 s . c om*/ public class Main { public static void main(String[] argv) throws FileNotFoundException { Throwable t = new Exception("from java2s.com"); t.printStackTrace(new PrintWriter("file.name")); } }