0

I'm developing using an older Java version which has no getStackTrace() method. There is a printStackTrace method but it's not printing where I want it.

Is there a way to extract the full contents of Exception ex (ex in this case, and a MXExeption)?

Cast to string array or something?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Baked Inhalf
  • 3,375
  • 1
  • 31
  • 45

1 Answers1

3

Maybe that helps:

StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ex.printStackTrace(pw);
String stacktrace = sw.getBuffer().toString();
DirkNM
  • 2,614
  • 15
  • 21