小编Jes*_*elo的帖子

测量下载速度Java

我正在努力下载一个软件上的文件,这是我得到的,它的sucesfully下载,我也可以取得进展,但还有一件事,我不知道该怎么做.测量下载速度.我很感激你的帮助.谢谢.这是当前的下载方法代码

    public void run()
    {
        OutputStream out = null;
        URLConnection conn = null;
        InputStream in = null;
        try
        {
            URL url1 = new URL(url);
            out = new BufferedOutputStream(
            new FileOutputStream(sysDir+"\\"+where));
            conn = url1.openConnection();
            in = conn.getInputStream();
            byte[] buffer = new byte[1024];
            int numRead;
            long numWritten = 0;
            double progress1;
            while ((numRead = in.read(buffer)) != -1)
            {
                out.write(buffer, 0, numRead);
                numWritten += numRead;
                this.speed= (int) (((double)
                buffer.length)/8);
                progress1 = (double) numWritten;
                this.progress=(int) progress1;
            }
        }
        catch (Exception ex)
        {
            echo("Unknown Error: …
Run Code Online (Sandbox Code Playgroud)

java file download measure

6
推荐指数
1
解决办法
1万
查看次数

Android通知进度条冻结

这是我正在使用的代码

http://pastebin.com/3bMCKURu

问题是,经过一段时间(文件获得更多权重)通知栏下拉速度变慢,最后它就冻结了!

java notifications android progress-bar

4
推荐指数
2
解决办法
2844
查看次数

标签 统计

java ×2

android ×1

download ×1

file ×1

measure ×1

notifications ×1

progress-bar ×1