import java.io.*;
// 缓冲字节流实现视频文件的拷贝
public class BufferedByteStreamCopy {
public static void main(String[] args) {
long l1 = System.currentTimeMillis();
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream("F:\\Program Files\\CDA\\录屏\\20201119_大数据java第一次实战.mp4"));
bos = new BufferedOutputStream(new FileOutputStream("F:\\Program Files\\CDA\\录屏\\大数据java第一次实战copy2.mp4"));
byte[] bytes = new byte[1024];
int res=0;
while ((res=bis.read(bytes)) != -1){
bos.write(bytes, 0, res);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (bos!=null){
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(bis!=null){
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
long l2 = System.currentTimeMillis();
System.out.println("缓冲字节流用时时长:" + (l2-l1));
}
}