java转换异常对象为String

 private static String transferException2String(Exception e) {
        try {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            e.printStackTrace(pw);
            return sw.toString();
        } catch (Exception e2) {
            return e.getMessage();
        }
    }

猜你喜欢

转载自halfsking.iteye.com/blog/2324564
今日推荐