下载文件时有趣的byte []计数

时间:2014-01-08 15:30:20

标签: android inputstream androidhttpclient

使用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();

虽然下载网址是常量,但&#34;计数&#34;下载完成后可以是不同的数字。

而且,我不知道为什么我从网址获取的文件总是我想要的。

下载时可能会发生什么?

0 个答案:

没有答案