hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wade Chandler <hwadechandler-apa...@yahoo.com>
Subject Re: Excel download question
Date Thu, 15 Sep 2005 10:03:08 GMT
--- Michael Becke <mbecke@gmail.com> wrote:

> Hi Keith,
> 
> This is because you are reading binary bytes from
> the HTTP response
> and writing them as text integers to a PrintWriter. 
> You'll want to
> use getOutputStream() instead of getWriter().  I
> also suggest
> reading/writing more than one byte at a time.
> 
=============================
Or wrap your input and output streams with a
BufferedOutputStream....this is just one way to write
more bytes at the same time.
=============================

> Mike
> 
> On 9/14/05, Keith Campbell <KCampbell@paperloop.com>
> wrote:
> > Hi all,
> > 
> > I'm trying to use HttpClient to download an excel
> file from a web
> > application.
> > 
> > Everything works but in my final excel document I
> get a series of
> > meaningless integers printed out to the document.
> > Am I missing something obvious?
> > 
> > 
> > xml = method.getResponseBodyAsStream();
> > 
> > PrintWriter out = response.getWriter();
> > 
> > response.setHeader(
> "content-disposition","attachment;
> > filename=projectList.xls" );
> >
> response.setContentType("application/vnd.ms-excel");
> > 
> > int excel;
> > while((excel=xml.read())!=-1){
> >      out.print(excel);
> > }
> > 
> > Thanks in advance,
> > Keith


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


Mime
View raw message