URLTemplateSource extends AbstractTemplateSource { @Override public String content(final Charset charset) throws IOException { Reader reader = null; final int bufferSize = 1024; try { reader = reader(charset); char[] cbuf = new char[bufferSize]; StringBuilder sb = new StringBuilder(bufferSize); int len; while ((len = reader.read(cbuf, 0, bufferSize)) != -1) { sb.append(cbuf, 0, len); } return sb.toString(); } finally { if (reader != null) { reader.close(); } } } URLTemplateSource(final String filename, final URL resource); @Override String content(final Charset charset); @Override String filename(); @Override long lastModified();  }
@Test public void content() throws Exception { URLTemplateSource templateSource = new URLTemplateSource("template.hbs", getClass().getResource("/template.hbs")); assertEquals("template.hbs", templateSource.content(StandardCharsets.UTF_8)); }