How can I convert a stack trace to a string?

前端 未结 30 1430
再見小時候
再見小時候 2020-11-22 14:51

What is the easiest way to convert the result of Throwable.getStackTrace() to a string that depicts the stacktrace?

30条回答
  •  迷失自我
    2020-11-22 15:20

    One can use the following method to convert an Exception stack trace to String. This class is available in Apache commons-lang which is most common dependent library with many popular open sources

    org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(Throwable)

提交回复
热议问题