1

textarea的我想打印一個拋出的堆棧跟蹤到一個textarea打印堆棧跟蹤到JavaFX中

事情是這樣的:

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

這可能嗎?

我希望你能幫助我

感謝

+0

[我怎麼能轉換一個堆棧跟蹤字符串?(HTTP的可能重複://計算器.com/questions/1149703/how-can-i-convert-a-stack-trace-to-a-string) – fabian

回答

2

你可以做

StringWriter stackTraceWriter = new StringWriter(); 
throwableElement.printStackTrace(new PrintWriter(stackTraceWriter)); 
textArea.setText(throwableElement.toString() + "\n" + stackTraceWriter.toString()); 
+0

This works!非常感謝:D –