ripper234 ripper234 - 9 months ago 47
Java Question

Get current stack trace in Java

How do I get the current stack trace in Java, like how in .NET you can do


is not what I want - I want to get the stack trace back, not print it out.


You can use Thread.currentThread().getStackTrace().

That returns an array of StackTraceElements that represent the current stack trace of a program.