使用 DefaultHttpClient 在线下载文件时,我得到了一个有趣的结果。代码粘贴在这里:
InputStream is = httpEntity.getContent();
int count=0;
byte buf[] = new byte[1024];
do {
count++;
int result = is.read(buf);
if ( result < 0) {
break;
}
} while (!cancelDownload);
Log.e(TAG, "count:" + count);
is.close();
虽然下载 url 是不变的,但下载完成后,“count”可以是不同的数字。
而且,我不知道为什么我从 url 得到的文件总是我想要的。
我的下载可能会发生什么?