How to download file using HttpClient using java

In this article we will explore apche HttpClient API. It is one of the popular client is used to communicate with rest services.

Especially, in this article we are going to discuss following topics

  • How to create HttpClient with SSL enabled :
  • It is important, because without enabling SSL, we can’t communicate with Rest API which is deployed in https environment. (http protocol is disabled). The following code snippet, explains to create Http Client with SSL
  • How to set authentication headers to HttpClient
  • Next step is, set authentication headers to communicate rest api which has security. Check the following code
  • How to download a file using HttpClient with SSL enabled
  • The following example demonstrates how write a simple HttpClient to download file from server using REST API call in secured environment

    To compile and execute the following program we required below jar in build path.

    Click here to Download jar files
    • httpclient-4.4.jar
    • httpcore-4.4.jar
    SOURCE: FileDownloadHttpClient.java

Vijay D

Hi, I have written and developed this post so that most of people will be benefited. I'm committed to provide easy and in-depth tutorials on various technologies.I hope it will help you a lot.

- Thulasiram P

Follow Me @Google+
SHARE

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment