---
title: "android下载问题。本地与网络资源大小不一致解决方法"
author: "flyering"
date: "2012-07-04T09:02:21Z"
tags: []
categories: ["移动开发"]
slug: "android"
draft: false
lastmod: "2012-07-04T09:02:21Z"
id: 1576181
url: "https://flyering.iteye.com/blog/1576181"
---

之前的代码：如下
output = new FileOutputStream(file);
	byte buffer = new byte;
	while ((input.read(buffer)) != -1) {
		output.write(buffer);
			}
修改好的代码：


output = new FileOutputStream(file);
	byte buffer = new byte;
	**int length=0;**	
while ((length  = input.read(buffer)) != -1) {
		output.write(buffer, 0, length);
			}