I am using Apache HTTP Client to get file stream from url on Android,I want to check header of the stream to determine whether I should load the entire file, to avoid meaningless cost of network resource.
For now, I use the following code the get the inStream and just read the first few bytes from it:
response = mClient.execute(method, localcontext);
final HttpEntity entity = response.getEntity();
if (entity != null) {
InputStream instream = entity.getContent();
byte[] ints = new byte[2];
instream.read(ints);
}
I am wondering if the whole file will be loaded in the above procedure. Should I close the stream explicitly. How?
Thanks~