You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Ivo Danihelka (JIRA)" <ta...@jakarta.apache.org> on 2005/04/28 11:10:25 UTC

[jira] Commented: (TAPESTRY-305) Wrong example for file download

     [ http://issues.apache.org/jira/browse/TAPESTRY-305?page=comments#action_63958 ]
     
Ivo Danihelka commented on TAPESTRY-305:
----------------------------------------

Now I'm sure that the example in FAQ is definitely wrong because
the "in.read(data)" can read less bytes not only at the end of file.


> Wrong example for file download
> -------------------------------
>
>          Key: TAPESTRY-305
>          URL: http://issues.apache.org/jira/browse/TAPESTRY-305
>      Project: Tapestry
>         Type: Bug
>   Components: Documentation
>     Versions: unspecified
>     Reporter: Ivo Danihelka
>     Priority: Minor

>
> Method InputStream.read(buffer) returns number of bytes read into the buffer.
> Tapestry FAQ contains example "How do I stream a file to the user from tapestry?":
>     byte[] data = new byte[1024];
> ...
>     while (in.read(data) > -1)
>     {
>         out.write(data);
>     }
> =============
> It should be something like:
>     int len;
>     while ((len = in.read(data)) > -1)
>     {
>         out.write(data, 0, len);
>     }
> =============
> Or I'm wrong and response.setContentLength() will handle this?
> Tapestry FAQ:
> http://jakarta.apache.org/tapestry/faq.html#faq-N1012F

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org