package com.lovecoding.day21.ex02;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.FileOutputStream;

public class TestInputOut {

    @Test
    public void test02() throws Exception {
        //创建
        //输入
        FileInputStream fis = new FileInputStream("E:\\a\\a.mp4");
        //输出
        FileOutputStream fos = new FileOutputStream("D:\\b.mp4");
        //数组
        byte[] bytes = new byte[8192];
        //循环读取
        int len = 0;
        while (  (len = fis.read(bytes)) != -1 ){
            //输出
            fos.write(bytes,0,len);
        }

        //释放资源
        fos.close();
        fis.close();

    }

    @Test
    public void test01() throws Exception {
        //创建
        //输入
        FileInputStream fis = new FileInputStream("E:\\a\\a.mp4");
        //输出
        FileOutputStream fos = new FileOutputStream("D:\\b.mp4");

        //循环读取
        int len = 0;
        while (  (len = fis.read()) != -1 ){
            //输出
            fos.write(len);
        }

        //释放资源
        fos.close();
        fis.close();

    }
}
