[英]How to write to an OutputStream directly using Stringtemplate 4.x?
我不想調用.render()
並從某些模板中構建極大的Strings
。 在以前的版本中,您可以直接寫入OutputStream
,而不必將整個模板呈現為String
,然后將其寫出。
我嘗試使用ST.write()
與實例NoIndentWriter
但不產生輸出。
Stringtemplate
直接寫入OutputStream
? 如果要保持標准格式,可以使用AutoIndentWriter
。
ST template = group.getInstanceOf("YourTemplate");
OutputStreamWriter osWriter = new OutputStreamWriter(stream);
STWriter stWriter = new AutoIndentWriter(osWriter);
template.write(stWriter);
osWriter.flush();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.