How to write to OutputStream directly using Stringtemplate 4.x?

I don't want to call .render() and create extremely large Strings from some of my templates. In previous versions, you could directly write OutputStream instead of displaying the entire template in String and then writing it.

I tried using ST.write() with an instance of NoIndentWriter , but did not NoIndentWriter result.

How do you write directly to OutputStream using the latest version of Stringtemplate ?

+4
source share
1 answer

You can use AutoIndentWriter if you want to support standard formatting.

 ST template = group.getInstanceOf("YourTemplate"); OutputStreamWriter osWriter = new OutputStreamWriter(stream); STWriter stWriter = new AutoIndentWriter(osWriter); template.write(stWriter); osWriter.flush(); 
+2
source

All Articles