`
flyering
  • 浏览: 37546 次
  • 性别: Icon_minigender_1
  • 来自: 河北保定
社区版块
存档分类
最新评论

android下载问题。本地与网络资源大小不一致解决方法

阅读更多
之前的代码:如下
output = new FileOutputStream(file);
byte buffer[] = new byte[4 * 1024];
while ((input.read(buffer)) != -1) {
output.write(buffer);
}
修改好的代码:


output = new FileOutputStream(file);
byte buffer[] = new byte[4 * 1024];
int length=0;
while ((length  = input.read(buffer)) != -1) {
output.write(buffer, 0, length);
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics