Difference between printStackTrace() and toString()

后端 未结 7 1394
甜味超标
甜味超标 2020-12-08 02:06

I\'m curious as to what the difference is between printStackTrace() and toString(). At first sight, they seem to do the exact same thing.

Code:

7条回答
  •  执笔经年
    2020-12-08 02:18

    There is an Open Source java library called MgntUtils (written by me) that provides several methods that allow you to extract stacktrace as a String as well as to optionally filter based on parametric package prefix. See the javadoc for the method public static java.lang.String getStacktrace(java.lang.Throwable e, boolean cutTBS, java.lang.String relevantPackage) The library is available at Maven Central and Github

提交回复
热议问题