private static VelocityContext vc;
static {
vc = new VelocityContext();
}
public static void generateFile(String tempatePath, String destPath, Map<String, Object> attributes) {
Template template = Velocity.getTemplate(tempatePath, "UTF-8");
for (String key : attributes.keySet()) {
vc.put(key, attributes.get(key));
}
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(destPath), "UTF-8"));
template.merge(vc, bw);
bw.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bw != null) {
try {
bw.close();
} catch (IOException e) {
}
}
}
}
public static void main(String[] args) {
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("key", "value");
generateFile("路径/temp.vm", "路径/dest.html", attributes);
}
本文深入剖析了为何在软件开发领域,大多数程序员未能晋升为架构师的原因,从技术积累、思维方式、项目经验等多个角度进行详细阐述。

1078

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



