Thanks a lot Michael!

It works! :-)

       Regards,

                    Luca

-----Messaggio originale-----
Da: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]Per conto di
Michael Weller
Inviato: marted́ 10 settembre 2002 16.17
A: [EMAIL PROTECTED]
Oggetto: Re: R: Download a file using HttpUrlconnection class (??)


> Hello.

Hi!

>
> The problem is that I have to read a file that is on a different server,
not
> a string or a web-page....:-(
>
> What do you think about?
>

Well, I think I don't understand what you mean :)
This should work:
...doGet/doPost(..., HttpServletResponse res) {
BufferedInputStream bin = new BufferedInputStream(
            new URL(...).openStream(), 1024);
BufferedOutputStream bout = new BufferedOutputStream(
            res.getOutputStream(), 1024);
int num = -1;
byte[] buf=new byte[1024];
while ((num = bin.read(buf,0,1024))!= -1)
    bout.write(buf,0,num);
buf=null;
bin.close();
bin=null;

bout.close();
}

-mw

>  Thanks.
>
>                Luca
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to