2

私は Apache Velocity を使用しているので、*.vm ファイルがあり、その内容は "Hello $name" です。

Velocity.init();
VelocityContext context = new VelocityContext();
context.put("name", "Velocity");
StringWriter w = new StringWriter();
Velocity.mergeTemplate("testtemplate.vm", context, w);
System.out.println(" template : " + w);

このコードの結果は -

template : Hello Velocity!

私の仕事は、この結果をファイルに保存することです。プレースホルダーの代わりにファイルが実際の値になるように保存するにはどうすればよいですか (この特定のケースでは「Hello Velocity!」)。

4

1 に答える 1