代码例子:
Configuration freemarkerCfg = new Configuration();
freemarkerCfg.setClassForTemplateLoading(this.getClass(), "/");
freemarkerCfg.setEncoding(Locale.getDefault(), "UTF-8");
Template template; Locale.setDefault(Locale.ENGLISH);
try...{
template = freemarkerCfg.getTemplate("Hello.txt");
template.setEncoding("UTF-8");
HashMap root = newHashMap();
map.put("user", name);
//流
Writer out = new StringWriter();
//Writer out = new OutputStreamWriter(System.out);
//Writer outr = new PrintWriter(new BufferedWriter(new FileWriter("d:/liyong.txt")));
template.process(map, out);
System.out.println(out.toString());
}catch(Exception e)...{
e.printStackTrace();
}
5938

被折叠的 条评论
为什么被折叠?



