Hi,
I am using HttpClient for generating a FileDownLoad.
Let me give a small explanation of the scenario.
I have Webservice which returns me a file as an InputStream. I am using
Stripes as the Web Framework.
Here goes the code:
.....Other code
try {
HttpClient httpClient = new HttpClient();
GetMethod getMethod = new GetMethod(assetURL);
bufferedInputstream = new
BufferedInputStream(getMethod.getResponseBodyAsStream());
} catch (Exception e) {
} finally {
getMethod.releaseConnection();
}
StreamingResolution streamingResolution = new
StreamingResolution(contentType, bufferedInputstream);
// set the fileName in the StreamingResolution.This in turn sets the
appropriate response header.
streamingResolution.setFilename(fileName + "." + extension)
// return the FileInputStream wrapped in the resolution
return streamingResolution;
The problem I am facing is, If i close the connection in the finally block,
it throws IOException: Tring to read from an already closed Stream.
So can you tell me when will be the correct time to close the connection?
What is the correct way for FileDownload via HTTPClient?
Can you help?
--
View this message in context:
http://www.nabble.com/FileDownload-using-HttpClient-tp21557478p21557478.html
Sent from the HttpClient-User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]