在JavaFX中将Stacktrace打印到Textarea中 [英] Print Stacktrace into Textarea in JavaFX
本文介绍了在JavaFX中将Stacktrace打印到Textarea中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将一个throwable的堆栈跟踪打印到Textarea中
I would like to print the stacktrace of a throwable into a Textarea
类似这样的东西
textArea.setText(throwableElement.toString() + "\n" + throwableElement.printStackTrace());
有可能吗?
我希望您可以帮助我
谢谢
推荐答案
您可以做到
StringWriter stackTraceWriter = new StringWriter();
throwableElement.printStackTrace(new PrintWriter(stackTraceWriter));
textArea.setText(throwableElement.toString() + "\n" + stackTraceWriter.toString());
这篇关于在JavaFX中将Stacktrace打印到Textarea中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文