What is the java template engine/api for creating a text file?
You may check String Template (GitHub).
It looks like this:
import org.antlr.stringtemplate.*;
import org.antlr.stringtemplate.language.*;
StringTemplate hello = new StringTemplate("Hello, $name$", DefaultTemplateLexer.class);
hello.setAttribute("name", "World");
System.out.println(hello.toString());
Velocity is a pretty flexible templating engine.