在 JavaFX 中将 Stacktrace 打印到 Textarea
Print Stacktrace into Textarea in JavaFX
我想将 throwable 的堆栈跟踪打印到 Textarea
像这样:
textArea.setText(throwableElement.toString() + "\n" + throwableElement.printStackTrace());
这可能吗?
希望你能帮帮我
谢谢
你可以做到
StringWriter stackTraceWriter = new StringWriter();
throwableElement.printStackTrace(new PrintWriter(stackTraceWriter));
textArea.setText(throwableElement.toString() + "\n" + stackTraceWriter.toString());
我想将 throwable 的堆栈跟踪打印到 Textarea
像这样:
textArea.setText(throwableElement.toString() + "\n" + throwableElement.printStackTrace());
这可能吗?
希望你能帮帮我
谢谢
你可以做到
StringWriter stackTraceWriter = new StringWriter();
throwableElement.printStackTrace(new PrintWriter(stackTraceWriter));
textArea.setText(throwableElement.toString() + "\n" + stackTraceWriter.toString());