| Author |
Stack trace
|
duhit Choudhary
Ranch Hand
Joined: Apr 01, 2012
Posts: 64
|
|
hi all,
Can anybody tell me how to get stack track of the java program in order to get the program flow?
Thanks in Advance.
|
 |
ganapathi sundaram
Greenhorn
Joined: Feb 09, 2010
Posts: 11
|
|
Hi,
you can use printStackTrace() of the method from the exception object.
try{
}catch(Exception e){
e.printStackTrace();
}
As well, if you want to read entire stack trace to store it in another variable , you can try below
public java.lang.StackTraceElement[] getStackTrace();
StackTraceElement[] traces = null;
try{
}catch(Exception e){
traces = e.getStackTrace();
}
All the best..!
|
 |
Jan Hoppmann
Ranch Hand
Joined: Jul 19, 2010
Posts: 98
|
|
|
The current thread has a getStackTrace()-method as well.
|
Life is full of choices. Sometimes you make the good ones, and sometimes you have to kill all the witnesses.
|
 |
Ivan Jozsef Balazs
Ranch Hand
Joined: May 22, 2012
Posts: 380
|
|
It is not even necessary to catch an exception in order to access the stack trace.
|
 |
duhit Choudhary
Ranch Hand
Joined: Apr 01, 2012
Posts: 64
|
|
|
thanks to all of you.. i'll try to do all of your methods and will see which one is working for me !!!
|
 |
 |
|
|
subject: Stack trace
|
|
|