ExceptionUtil.java
760 Bytes
package com.infoloop.tianting.utils;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
public class ExceptionUtil {
public static String getMessage(Exception exception) {
StringWriter sw = null;
PrintWriter pw = null;
try {
sw = new StringWriter();
pw = new PrintWriter(sw);
exception.printStackTrace(pw);
sw.flush();
pw.flush();
} finally {
if (sw != null) {
try {
sw.close();
} catch (IOException ignored) {
}
}
if (pw != null) {
pw.close();
}
}
return sw.toString();
}
}