getTrace()

	/**
	 * 将e.printStackTrace()函数输出的对象转换为字符串输出
	 * @param e
	 * @return
	 */
	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();
	}

 

你可能感兴趣的:(Java)