ExceptionUtil

来源:互联网 发布:淘宝客转换软件 编辑:程序博客网 时间:2024/06/05 00:12
package com.taotao.common.utils;


import java.io.PrintWriter;
import java.io.StringWriter;


public class ExceptionUtil {


/**
* 获取异常的堆栈信息

* @param t
* @return
*/
public static String getStackTrace(Throwable t) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);


try {
t.printStackTrace(pw);
return sw.toString();
} finally {
pw.close();
}
}
}
0 0