Convert Exception to String output in java

Convert Exception to String output in java

First, the code is implemented as follows:

    

/**
	 * Convert Exception to String
	 */
	public static String getExceptionToString(Throwable e) {
		if (e == null){
			return "";
		}
		StringWriter stringWriter = new StringWriter();
		e.printStackTrace(new PrintWriter(stringWriter));
		return stringWriter.toString();
	}


Supplementary information:
        Detailed study of java exception:  http://www.cnblogs.com/Qian123/p/5715402.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325741211&siteId=291194637