Print Stacktrace into Textarea in JavaFX

后端 未结 1 1074
借酒劲吻你
借酒劲吻你 2021-01-25 13:18

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

Something like this:

textArea.setText(throwableElement.toString() + \"\\n\" + throwab         


        
相关标签:
1条回答
  • 2021-01-25 13:51

    You can do

    StringWriter stackTraceWriter = new StringWriter();
    throwableElement.printStackTrace(new PrintWriter(stackTraceWriter));
    textArea.setText(throwableElement.toString() + "\n" + stackTraceWriter.toString());
    
    0 讨论(0)
提交回复
热议问题