I don't want to call .render()
and build extremely large Strings
from some of my templates. In previous versions you could write to an OutputStream
directly instead of having to render the entire template to a String
and then write that out.
I tried using ST.write()
with an instance of NoIndentWriter
but that produces no output.
How do you write directly to an OutputStream
using the latest version of Stringtemplate
?
You can use the AutoIndentWriter
if you want to maintain the standard formatting.
ST template = group.getInstanceOf("YourTemplate");
OutputStreamWriter osWriter = new OutputStreamWriter(stream);
STWriter stWriter = new AutoIndentWriter(osWriter);
template.write(stWriter);
osWriter.flush();