小编Lij*_*Joy的帖子

简历下载不在android中工作

这个恢复下载的代码在Android中无法正常工作,尽管它在Java应用程序中运行良好.在这里,我试图下载一个zip文件,它将恢复下载,但最终结果是一个无效的zip文件.

 BufferedInputStream in = null;
        FileOutputStream fos = null;
        BufferedOutputStream bout=null;

        try {
            downloaded=0;
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            if(ISSUE_DOWNLOAD_STATUS.intValue()==ECMConstant.ECM_DOWNLOADING){
                File file=new File(DESTINATION_PATH);
                if(file.exists()){
                    downloaded = (int) file.length();
                }
            }
            connection.setRequestProperty("Range", "bytes=" + downloaded + "-");
            connection.connect();
            size=connection.getContentLength();
            Dialog.setMax(size);
             in = new BufferedInputStream(connection.getInputStream());
             fos=(downloaded==0)? new FileOutputStream(DESTINATION_PATH): new FileOutputStream(DESTINATION_PATH,true);
             bout = new BufferedOutputStream(fos, 1024);
            byte[] data = new byte[1024];
            int x = 0;
            while ((x = in.read(data, 0, 1024)) >= 0) {
                bout.write(data, 0, x);
                 downloaded += x;
                 System.out.println(downloaded);
                 onProgressUpdate((int)(downloaded*100/size));
            } …
Run Code Online (Sandbox Code Playgroud)

android resume-download

9
推荐指数
1
解决办法
6149
查看次数

在大气框架中实现HeartBeat(Android)

1)我们如何在Android中实现心跳.我已经实施了Atmosphere框架.

目前发生的事情是webscoket连接被解雇,我们无法识别

java android atmosphere

5
推荐指数
0
解决办法
404
查看次数

标签 统计

android ×2

atmosphere ×1

java ×1

resume-download ×1