Android:了解下载过程

Android:了解下载过程,android,download,wifi,inputstream,Android,Download,Wifi,Inputstream,我正在计算我的wifi速度。所以我从服务器下载了一个文件(10MB)。下载效果很好。但我不知道如何计算每个接收到的数据包的下载许可证 这是我正在使用的代码的一部分。我想了解两种尺寸之间的区别:8192和1024,每种尺寸的紫色 InputStream input = new BufferedInputStream(url.openStream(), 8192); 这条线呢 byte data[] = new byte[1024]; 我就是这样使用它们的: protected String

我正在计算我的wifi速度。所以我从服务器下载了一个文件(10MB)。下载效果很好。但我不知道如何计算每个接收到的数据包的下载许可证

这是我正在使用的代码的一部分。我想了解两种尺寸之间的区别:8192和1024,每种尺寸的紫色

 InputStream input = new BufferedInputStream(url.openStream(), 8192);
这条线呢

 byte data[] = new byte[1024];
我就是这样使用它们的:

protected String doInBackground(String... f_url) {
    int count;
    int lenghtOfFile = 0;

    try {
        URL url = new URL(f_url[0]);
        comm = (HttpURLConnection)url.openConnection();
        URLConnection conection = url.openConnection();
        conection.connect();
         lenghtOfFile = conection.getContentLength();

        // download the file
        InputStream input = new BufferedInputStream(url.openStream(), 8192);

        // Output stream
        OutputStream output = new FileOutputStream("/sdcard/downloadedfile.jpg");

     byte data[] = new byte[1024];
        long total = 0;
        while ((count = input.read(data)) != -1) {
            actuaStartlTime = System.currentTimeMillis();
            total += count;

}}

这是一个输出示例:curret time和下载的数据。我看不到下载数据的大小之间有任何关系

    05-06 15:32:36.883: I/downloaded data(13146): 244392
05-06 15:32:36.883: I/current time in millisecond(13146): 1399386756881
05-06 15:32:37.329: I/downloaded data(13146): 245840
05-06 15:32:37.329: I/current time in millisecond(13146): 1399386757328
05-06 15:32:37.331: I/downloaded data(13146): 247288
05-06 15:32:37.332: I/current time in millisecond(13146): 1399386757330
05-06 15:32:37.334: I/downloaded data(13146): 250184
05-06 15:32:37.334: I/current time in millisecond(13146): 1399386757333
05-06 15:32:37.347: I/downloaded data(13146): 251632
05-06 15:32:37.347: I/current time in millisecond(13146): 1399386757345
05-06 15:32:37.349: I/downloaded data(13146): 262144
05-06 15:32:37.349: I/current time in millisecond(13146): 1399386757348
05-06 15:32:37.637: I/downloaded data(13146): 288208
05-06 15:32:37.637: I/current time in millisecond(13146): 1399386757636
05-06 15:32:38.050: I/downloaded data(13146): 289656
05-06 15:32:38.050: I/current time in millisecond(13146): 1399386758049
05-06 15:32:38.063: I/downloaded data(13146): 298344
05-06 15:32:38.063: I/current time in millisecond(13146): 1399386758062
05-06 15:32:38.067: I/downloaded data(13146): 304136
05-06 15:32:38.068: I/current time in millisecond(13146): 1399386758066
05-06 15:32:38.070: I/downloaded data(13146): 309928
05-06 15:32:38.071: I/current time in millisecond(13146): 1399386758069
05-06 15:32:38.079: I/downloaded data(13146): 317168

提前感谢。

现在是时候亲自看看这些缓冲区大小是否会影响下载速度了。我想是的。请尝试并制作一个包含大小和时间的表格。谢谢您的回复。@greenapps请重新发布我的帖子,我添加了一个表格。这看起来不像一个表格。你没有解释你打印了哪些值。我要求提供一个表,在该表中,您使用了不同大小的新字节[1024]作为缓冲区;试用2048,然后下载并测量时间。然后切换到4096,下载并再次测量时间。增加缓冲区大小。对中的8192执行相同的操作(url.openStream(),8192)。