80,371
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
private static final int COPY_BUFFER_SIZE = 2 * 1024 * 1024; //2MB一次
input = new FileInputStream(oldFile);
output = new FileOutputStream(newFile);
byte[] buffer = new byte[COPY_BUFFER_SIZE];
while (true) {
int bytes = input.read(buffer);
if (bytes <= -1) {
result = 1;
break;
}
output.write(buffer, 0, bytes);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
// close all stream
if (input != null) {
input.close();
}
if (output != null) {
output.close();
}
}
//在这里显示提示信息 已复制完毕