Code example for StringWriter

Methods: flush, toString

0
			prop.put("input.encoding", "UTF-8");
			prop.put("output.encoding", "UTF-8");
			Velocity.init("src/velocity.properties"); 
			VelocityContext context = new VelocityContext();
			Template template = Velocity.getTemplate("helloworld.vm");
			StringWriter sw = new StringWriter();
			template.merge(context, sw);
			sw.flush();
			System.out.println(sw.toString());
		} catch (Exception e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
		} 
	} 
 
}