把异常的栈轨迹以String形式返回

    /**
     * 把异常的栈轨迹以String形式返回,而不是直接打印到console
     * @author King
     * @time 2015-04-29
     * @return
     */
    public static String getLongInfo(Throwable e){   
        StringWriter sw = new StringWriter();   
        PrintWriter pw = new PrintWriter(sw, true);   
        e.printStackTrace(pw);   
        pw.flush();   
        sw.flush();   
        return sw.toString();   
    } 

  

相关文章:

  • 2021-05-18
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2022-01-31
  • 2021-10-04
  • 2022-02-10
猜你喜欢
  • 2022-01-26
  • 2022-03-03
  • 2022-12-23
  • 2021-10-31
  • 2022-12-23
  • 2021-11-16
  • 2022-01-09
相关资源
相似解决方案