apache common中的exceptionutils

在日常处理中,一般对异常的处理是e.printstrace,但如要记录到 string的话,
一般是这个做法:

   StringWriter sw = new StringWriter();
                    PrintWriter pw = new PrintWriter(sw);
                    e.printStackTrace(pw);
                    errorMsg = sw.toString();


   但如果用apache common包,则可以有这个exceptionutils,
String str = org.apache.commons.lang3.exception.ExceptionUtils.getStackTrace(Throwable);

猜你喜欢

转载自jackyrong.iteye.com/blog/2282098