【FileInputStream类:读取数组】

package test;

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

/**
 * @author shusheng
 * @description
 * @Email shusheng@yiji.com
 * @date 2018/11/9 16:16
 */
public class FileInputStreamDemo2 {

    public static void main(String[] args) throws IOException {
        //封装数据源
        FileInputStream fis = new FileInputStream("d:\\aaa.zip");

        //封装目的地
        FileOutputStream fos = new FileOutputStream("e:\\bbb.zip");

        //读取数据
        //定义一个字节数据
        //数组的长度一般是1024或者1024的整数倍
        byte[] by = new byte[1024];    
        int len = 0;
        while ((len = fis.read(by)) != -1) {
            fos.write(by);
        }
    }

}

 

posted @ 2018-11-11 00:10  书丶生  阅读(571)  评论(0编辑  收藏  举报