0
我将使用Apache HTTP客户端从Android上的url获取文件流,我想检查流的标题来确定是否应该加载整个文件,以避免网络资源的无谓成本。
现在,我用下面的代码获得进入数据流,并从它刚刚看了前几个字节:当我刚刚读取前几个字节使用Apache HTTP客户端,Java,Android
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);
}
我想知道如果整个文件将在上述过程中被加载。我应该明确关闭这个流。怎么样?
谢谢〜
对不起,但是当我说流的标头时,我实际上是指实体内容的前面部分:P – Bolton
我只想知道在阅读了我想要的数据后是否应该关闭流。 – Bolton
是的。它是一条小溪。所以数据不断流动,当你关闭它时,它就会停止。 – Santosh