Java Throwable .printStackTrace (PrintWriter s)

Syntax

Throwable.printStackTrace(PrintWriter s) has the following syntax.

public void printStackTrace(PrintWriter s)

Example

In the following code shows how to use Throwable.printStackTrace(PrintWriter s) method.


import java.io.FileNotFoundException;
import java.io.PrintWriter;
//  w ww .  ja v a  2  s .  c o  m

public class Main {
  public static void main(String[] argv) throws FileNotFoundException {
    Throwable t = new Exception("from java2s.com");
    
    t.printStackTrace(new PrintWriter("file.name"));


  }

}




















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable