Code example for StringWriter

Methods: flushtoString

0
	 *  
	 * @param t a Throwable 
	 * @return the whole stacktrace in a String 
	 */ 
	public static String getStackTrace(Throwable t) {
		StringWriter sw = new StringWriter();
		PrintWriter pw = new PrintWriter(sw, true);
		t.printStackTrace(pw);
		pw.flush();
		sw.flush();
		return sw.toString();
	} 
 
	private final static long secondsInAMonth = 30L * 24L * 60L * 60L;
 
	/** 
	 * Adds Expires, ETag and Cache-Control response headers. 
	 *  
	 * @param response the HTTP servlet response 
	 * @param etag the calculated etag (md5) of the response 
Connect your IDE to all the code out there  Get Codota for Java