java110
2021-10-19 43d91615f57c7f7cfaf231496739ae750025bd5f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.java110.utils.util;
 
import java.io.PrintWriter;
import java.io.StringWriter;
 
/**
 * 异常工具类
 */
public class ExceptionUtil {
 
    public static String getStackTrace(Throwable throwable) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
 
        try {
            throwable.printStackTrace(pw);
            return sw.toString();
        } finally {
            pw.close();
        }
    }
}