Code example for PrintWriter

Methods: close, print

0
		if(obj != null) {
			response.setCharacterEncoding(ENCODING);
			response.setHeader("Content-Type", "application/json; charset=" + ENCODING);
			PrintWriter writer = response.getWriter();
			try{ 
				writer.print(Json.toJson(obj));
			} finally { 
				writer.close();
			} 
		} 
	} 
 
}