Code example for StringWriter

Methods: flushtoString

0
 
  public String render(String name, Map context) {
    try { 
      Template template = fm.getTemplate(name);
 
      StringWriter writer = new StringWriter();
      template.process(context, writer);
      writer.flush();
      return writer.toString();
    } catch (IOException e) {
      throw new RuntimeException(e);
    } catch (TemplateException e) {
      throw new RuntimeException(e);
    } 
  } 
} 
Contextual code suggestions in your IDE  Get Codota for Java