Java Throwable .setStackTrace (StackTraceElement [] stackTrace)

Syntax

Throwable.setStackTrace(StackTraceElement [] stackTrace) has the following syntax.

public void setStackTrace(StackTraceElement [] stackTrace)

Example

In the following code shows how to use Throwable.setStackTrace(StackTraceElement [] stackTrace) method.


import java.io.FileNotFoundException;
import java.io.PrintWriter;
//  ww w .  j  ava2  s  .co  m

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


  }

}




















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