Java getting exception.printStackTrace as a string

In cases like when I simply want to make a System.out.println or similar with some details of a exception then the following static helper function is very nice as it takes the exception (uses printStackTrace) and returns a string with the contents of it.

public static String getStackTrace(Exception e){
	StringWriter stringWriter = new StringWriter();
	PrintWriter printWrtier = new PrintWriter(stringWriter);
	e.printStackTrace(printWrtier);
	return stringWriter.toString();
}