Java IO字节缓冲流实现复制文件。 -小记

浮夸小生。
2021-09-26 / 1 评论 / 317 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2021年09月26日,已超过936天没有更新,若内容或图片失效,请留言反馈。
package demo16;

import java.io.*;

public class Demo03CopyFor {
    public static void main(String[] args) throws IOException {
        long e = System.currentTimeMillis();
        FileInputStream fis = new FileInputStream("D:\\C0103.MP4");
        BufferedInputStream bis = new BufferedInputStream(fis);

        FileOutputStream fos = new FileOutputStream("E:\\C0103.MP4");
        BufferedOutputStream bos = new BufferedOutputStream(fos);
        byte[] bytes = new byte[10240];
        int len = 0;
        while ((len = bis.read(bytes))!= -1){
            bos.write(bytes);
        }

        bis.close();
        bos.close();
        long s = System.currentTimeMillis();
        System.out.println("系统总耗时:"+(s-e)+"毫秒~");
    }
}

系统总耗时:40毫秒~

0

评论 (1)

取消
  1. 头像
    测试
    iPhone · Safari

    你好

    回复