阅读更多
之前的代码:如下
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);
}