如何成为Android开发高手
2010-08-31 00:43:00 来源:WEB开发网328
329RandomAccessFile randOut = new RandomAccessFile(this.saveFile, "rw");
330
331if(this.fileSize>0) randOut.setLength(this.fileSize);
332
333randOut.seek(this.data.get(i+1));
334
335this.threads[i] = new DownloadThread(this, this.url, randOut, this.block, this.data.get(i+1), i+1);
336
337this.threads[i].setPriority(7);
338
339this.threads[i].start();
340
341}else{
342
343this.threads[i] = null;
344
345}
346
347}
348
349this.fileService.save(this.downloadUrl, this.data);
350
351boolean notFinish = true;//下载未完成
352
353while (notFinish) {// 循环判断是否下载完毕
354
355Thread.sleep(900);
356
357notFinish = false;//假定下载完成
358
359for (int i = 0; i < this.threads.length; i++){
360
361if (this.threads[i] != null && !this.threads[i].isFinish()) {
362
363notFinish = true;//下载没有完成
364
365if(this.threads[i].getDownLength() == -1){//如果下载失败,再重新下载
366
367RandomAccessFile randOut = new RandomAccessFile(this.saveFile, "rw");
368
369randOut.seek(this.data.get(i+1));
370
371this.threads[i] = new DownloadThread(this, this.url, randOut, this.block, this.data.get(i+1), i+1);
372
373this.threads[i].setPriority(7);
374
375this.threads[i].start();
376
377}
378
379}
380
381}
382
383if(listener!=null) listener.onDownloadSize(this.downloadSize);
更多精彩
赞助商链接