1

I would like to print the stacktrace of a throwable into a Textarea

Something like this:

textArea.setText(throwableElement.toString() + "\n" + throwableElement.printStackTrace());

Is that possible?

I hope you can help me

Thanks

Siro Duschletta
  • 283
  • 1
  • 4
  • 15
  • Possible duplicate of [How can I convert a stack trace to a string?](http://stackoverflow.com/questions/1149703/how-can-i-convert-a-stack-trace-to-a-string) – fabian Oct 29 '15 at 11:23

1 Answers1

4

You can do

StringWriter stackTraceWriter = new StringWriter();
throwableElement.printStackTrace(new PrintWriter(stackTraceWriter));
textArea.setText(throwableElement.toString() + "\n" + stackTraceWriter.toString());
James_D
  • 201,275
  • 16
  • 291
  • 322