I am new to using the streams.I am trying to download zipfile using httpClient in my appliation.when I am downloading the zip file I am getting the sucessfull response from the client.with the response I am trying to generate the zipfile in my local folder using the inputstream.I am able to generating the zip file but there is no content.can somebody help me out here. below is my code snippet.
String url = CONTANTS.SERVER_LOCATION+"Download/Test/"+ "sudhakar_test.zip";
HttpGet getRequest = new HttpGet(url);
CloseableHttpClient httpClient =HttpClientBuilder.create().build();
try (
CloseableHttpResponse response = httpClient.execute(getRequest);
InputStream fileInput = response.getEntity().getContent();
ZipInputStream zipInput = new ZipInputStream (fileInput);
FileOutputStream output = new FileOutputStream(new File(fileLocation
+"/SudhakarZIP_Test.zip"));
)
{
if (response.getStatusLine().getStatusCode() == 200)
{
byte[] buffer = new byte[1024];
int length;
while((length = zipInput.read(buffer,0,buffer.length)) >0)
{
output.write(buffer,0,length);
}
}