1 第一种
public static String getTrace(Throwable e) {
StringWriter stringWriter = new StringWriter();
PrintWriter writer = new PrintWriter(stringWriter);
e.printStackTrace(writer);
StringBuffer buffer = stringWriter.getBuffer();
return buffer.toString().replace("\n", "").replace("\r", "");
}
下图不换行
2 第二种 下图自动带换行,占用空间大
提示 {} 针对变量 ,但不适用于对象