hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vijay Gomatam" <vijayraman.goma...@gmail.com>
Subject Re: Hi ... httpclient for PDF files ???
Date Tue, 28 Mar 2006 16:04:10 GMT
Hi Ortwin,

Thanks for the reply... I tried to get the InputStream and put it to a
fileoutputstream and look into the file! I see the new file which is a few
KB lesser than the original file !!

For a clearer pic , I am attaching a code snippet! Is this a right approach?

// -----
HttpClient httpClient=*new* HttpClient();

httpClient.setConnectionTimeout(_connectionCreateTimeout);

httpClient.setTimeout(_connectionReadTimeout);

postMethod=*new* PostMethod(url);

postMethod.setFollowRedirects(*false*);

httpClient.executeMethod(postMethod);

InputStream responseBodyStream = postMethod.getResponseBodyAsStream();

DataInputStream data = new DataInputStream(new
BufferedInputStream(responseBodyStream));

FileOutputStream fos = new FileOutputStream("rwservlet.pdf");

*while* ((c =data.read(b)) != -1){

*byte*[] inter=*new* *byte*[c];

*for*(*int* i=0;i<c;i++)  inter[i]=b[i];

fos.write(inter);

}

data.close();

// -----

Thanks a ton ...
Regards,
Vijay.


On 3/28/06, Ortwin Glück <odi@odi.ch> wrote:
>
> Vijay,
>
> HttpClient is completely content agnostic. You can use it to transfer
> arbitrary data, including PDFs.
>
> Ortwin Glück
>
> Vijay Gomatam wrote:
> > Hi ..
> >
> > I am using httpclient for a few hours ... I have just downloaded the jar
> > 3.0over the weekend!
> >
> > I tried to retrieve a remote pdf file, but the inputstream doesn't give
> me
> > the properly formatted original file!
> >
> > Would httpclient support the pdfs? If so, is there anything I need to
> > configure further to see the original pdf ??
> >
> > Thanks!
> > Vijay.
> >
>
> --
> [web]  http://www.odi.ch/
> [blog] http://www.odi.ch/weblog/
> [pgp]  key 0x81CF3416
>        finger print F2B1 B21F F056 D53E 5D79 A5AF 02BE 70F5 81CF 3416
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message