As you know, there is no content length for sending a chunked file in the HTTP header, so the program must wait 0 to understand that this file has ended.
You can use the following code to get this file.
ResponseHandler<String> reshandler = new ResponseHandler<String>() { public String handleResponse(HttpResponse response) throws ClientProtocolException, IOException { HttpEntity entity = response.getEntity(); InputStream in = entity.getContent(); byte[] b = new byte[500]; StringBuffer out = new StringBuffer(); int len = in.read(b); out.append(new String(b, 0 , len)); return out.toString(); } };
but in my case, I am working with a streaming channel in another word, there is no 0 that indicates that the file has ended. Anyway, if I use this code, it seems like it is waiting forever to wait for 0, which will never happen. my question is is there a better approach to getting a file with a channel from a channel channel?
source share