ExceptionUtil.java 571 Bytes
package zteits.rocketmq.spring.starter.utils;

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

public class ExceptionUtil {

    public static String getTrace(Throwable t) {
    	StringBuffer buffer = new StringBuffer();
    	if(t==null){
			return "";
		}
        StringWriter stringWriter = new StringWriter();
        PrintWriter writer = new PrintWriter(stringWriter);
        t.printStackTrace(writer);
        //设置堆栈信息
        buffer.append("堆栈信息为:" + stringWriter.getBuffer().toString());
        return buffer.toString();
    }

}