热线电话:13121318867

登录
2020-12-10 阅读量: 928
java中如何利用缓冲字节流实现视频文件的拷贝


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));

}

}


0.0000
0
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子