[ 
https://issues.apache.org/jira/browse/VELOCITY-339?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Henning Schmiedehausen closed VELOCITY-339.
-------------------------------------------


> Can't controll the output flushing.
> -----------------------------------
>
>                 Key: VELOCITY-339
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-339
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 1.4
>         Environment: Operating System: Windows XP
> Platform: PC
>            Reporter: Arie
>         Assigned To: Velocity-Dev List
>
> It seems that When applying a template the output is buffered before it is 
> directed to the given writer. That can be a problem if the output is very big 
> and should be directed to a file.
> Here is a program to demonstrate the problem:
> import java.io.*;
> import org.apache.velocity.VelocityContext;
> import org.apache.velocity.Template;
> import org.apache.velocity.app.Velocity;
> import org.apache.velocity.exception.ResourceNotFoundException;
> import org.apache.velocity.exception.ParseErrorException;
> import org.apache.velocity.exception.MethodInvocationException;
> public class Test
> {
>       public static void main(String st[]) throws Exception
>       {
>               Obj[] objArray = new Obj[50];
>               for (int i = 0; i < 50; i++)
>                       objArray[i] = new Obj("name_" + i);
>               Velocity.init();
>               VelocityContext context = new VelocityContext();
>               context.put( "objArray", java.util.Arrays.asList(objArray) );
>               //Template template = Velocity.getTemplate("test.vtl");
>               //PrintWriter sw = new PrintWriter(new FileWriter
> ("output.txt"));
>               //org.apache.velocity.io.VelocityWriter sw = new 
> org.apache.velocity.io.VelocityWriter(new OutputStreamWriter(System.out), 10, 
> true);
>               //template.merge( context, sw );
>               String myStr = "<html>\n" + 
>                                               "<body>\n" + 
>                                               "#foreach( $key in $objArray )
> \n" + 
>                                               "    <li>$key.name</li>\n" + 
>                                               "#end\n" + 
>                                               "</body>\n" + 
>                                               "</html>\n";
>               Writer w = new PrintWriter(new OutputStreamWriter(System.out), 
> true);
>               Velocity.evaluate(context, w, "my-log-tag", myStr);
>               w.flush();
>               //sw.close();
>       }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to