You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by lu...@yahoo.co.jp on 2010/11/25 09:17:31 UTC

Re: How to download a file without creating it on a server

Hi,

I found the following the thread, and now I apply that method.
I think it is the best solution for this issue.(namely create custom Result
class)

http://www.mail-archive.com/user@struts.apache.org/msg79822.html 

Thanks.

Ken


--- lunch716@yahoo.co.jp wrote:

> Hi Dale,
> 
> Thank you for your reply.
> 
> It sounds I can make it, even though there might be some problems
> about
> closing streams.
> When I coded like the following, I could get the download file(i.e. I
> could
> concatenate the ByteArrayInputStream objects.
> )
> 
> Note.I must rely on SequenceInputStream refered by strtus2 to close
> all
> streams,even though it is possible
> SequenceInputStream.close(=nextStream)
> not to try to close all streams by throwing IOException.   
> 
> #### code #####
>     SequenceInputStream seq1 = null;
>     
>     ByteArrayInputStream bai1 = null;
>     ByteArrayInputStream bai2 = null;
>     ByteArrayInputStream bai3 = null;
>     
>     try {
>        String str1 = new String("aaa");
>        bai1 = new ByteArrayInputStream(str1.getBytes("UTF-8"));
>             
>        String str2 = new String("bbb");
>        bai2 = new ByteArrayInputStream(str2.getBytes("UTF-8"));
>        seq1 = new SequenceInputStream(bai1, bai2);
> 
>        String str3 = new String("ccc");
>        bai3 = new ByteArrayInputStream(str3.getBytes("UTF-8"));
>             
>        this.inputStream = new SequenceInputStream(seq1, bai3);
>         } catch (UnsupportedEncodingException e) {
>            
>             e.printStackTrace();
>         }finally{
>            //don't close streams(seq1, bai1, bai2, bai3) 
>         }
>    }
> ###############
> 
> Thanks.
> 
> Ken
> 
> --- Dale Newfield <da...@newfield.org> wrote:
> 
> > java.io.SequenceInputStream might prove helpful to you here, as
> well.
> > 
> > -Dale
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> > 
> > 
> 
> 
> --------------------------------------
> Get the new Internet Explorer 8 optimized for Yahoo! JAPAN
> http://pr.mail.yahoo.co.jp/ie8/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


--------------------------------------
What is the No.1 drama, music and car of 2010 ?
    - Yahoo! JAPAN  Net BANZUKE 2010 -
http://pr.mail.yahoo.co.jp/banzuke/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org