【java】学习路径41-使用缓冲输入输出复制文件
作者:互联网
结论:Buffered+数组 这种方式速度是最快的。
public void testBufferedIO(String source,String target){
BufferedInputStream bufferedInputStream = null;
BufferedOutputStream bufferedOutputStream= null;
try {
bufferedInputStream = new BufferedInputStream(new FileInputStream(source));
bufferedOutputStream= new BufferedOutputStream(new FileOutputStream(target));
byte[] data = new byte[1024];
int length = -1;
while ((length=bufferedInputStream.read(data))>-1){
bufferedOutputStream.write(data);
}
} catch (IOException e) {
e.printStackTrace();
}
}
标签:java,String,bufferedInputStream,输入输出,41,bufferedOutputStream,new,null,data 来源: https://www.cnblogs.com/remyuu/p/16221444.html