문제

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();
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top