use of org.apache.velocity.runtime.RuntimeServices in project Gargoyle by callakrsos.
the class MailUtil method getTemplateFromFile.
/**
* 파일로부터 템플릿 정보를 얻어온다.
*
* @Date 2015. 9. 13.
* @param templateFileName
* @return
* @throws Exception
* @User KYJ
*/
public static Template getTemplateFromFile(final String templateFileName) throws Exception {
String readFileToString = "";
if (templateFileName.startsWith("classpath:")) {
String res = templateFileName.replace("classpath:", "");
InputStream resourceAsStream = ClassLoader.getSystemClassLoader().getResourceAsStream(res);
readFileToString = ValueUtil.toString(resourceAsStream);
} else
readFileToString = FileUtils.readFileToString(new File(templateFileName));
RuntimeServices runtimeServices = RuntimeSingleton.getRuntimeServices();
StringReader reader = new StringReader(readFileToString);
SimpleNode node = runtimeServices.parse(reader, templateFileName);
Template template = new Template();
template.setRuntimeServices(runtimeServices);
template.setData(node);
template.initDocument();
return template;
}
Aggregations