最近做一个下载的模块。其中有个暂停的功能。
我实现的时候,是通过在while()循环的时候通过判断状态break掉的,但是在关闭流的时候出了问题
下边是伪代码InputStream is = HttpResponse.getEntity().getContent();while ((len = is.read(bs)) != -1) {
write();
if(cancle){
LogTag.showTAG_e("log", "download break");
break;
}}后边就是关闭流的代码了
long time = 0;
time = System.currentTimeMillis();
is.close();
time = System.currentTimeMillis() - time;
LogTag.showTAG_e("log", "close the inputstream cost====="+time);下边是日志========download break=============
========close the inputstream cost=====262014=============
我实现的时候,是通过在while()循环的时候通过判断状态break掉的,但是在关闭流的时候出了问题
下边是伪代码InputStream is = HttpResponse.getEntity().getContent();while ((len = is.read(bs)) != -1) {
write();
if(cancle){
LogTag.showTAG_e("log", "download break");
break;
}}后边就是关闭流的代码了
long time = 0;
time = System.currentTimeMillis();
is.close();
time = System.currentTimeMillis() - time;
LogTag.showTAG_e("log", "close the inputstream cost====="+time);下边是日志========download break=============
========close the inputstream cost=====262014=============
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货