public TemplateDocument parseTemplate(InputStream in) throws TemplateLoadingException {
return parseTemplate(in, DefaultEncoding);
}
public TemplateDocument parseTemplate(InputStream in, String encoding) throws TemplateLoadingException {
TemplateTokenizer tokenizer = null;
try {
tokenizer = new TemplateTokenizer(new InputStreamReader(in, encoding));
TemplateParser parser = new TemplateParser(tokenizer, this);
return parser.parse();
} catch (IOException e) {
throw new TemplateLoadingException(e);
} catch (TemplateParsingException e) {
throw new TemplateLoadingException(e);
} finally {
if (tokenizer != null) {
try {
tokenizer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}