[stringtemplate-interest] ST4: simple write to file method.
Udo Borkowski
ub at abego-software.de
Sun Jan 30 08:18:15 PST 2011
Sounds good to me.
Udo
On 30.01.2011, at 16:26, Collin Fagan wrote:
> Hi,
>
> I find myself constantly writing the output of templates to files. I was wondering if we could add a method to ST that writes directly to a file?
>
> Something like this:
>
> public int write(File outputFile) throws IOException {
> Writer writer = null;
> try {
> writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile)));
> int returnValue = write(new AutoIndentWriter(writer));
> writer.flush();
> return returnValue;
> } finally {
> try {
> if (writer != null) {
> writer.close();
> }
> } catch (IOException ex) {
> // what can you do when a close fails???
> // nothing :(
> }
> }
> }
>
> One might even provide a variant that lets you specify the encoding.
>
> Does something like this sounds useful?
>
> Thanks,
>
> Collin
>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110130/e5628576/attachment.html
More information about the stringtemplate-interest
mailing list