A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

package com.heim.io;

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

public class Demo4_Array {

        public static void main(String[] args) throws IOException {
                //字节流一次读写一个字节数组复制图片
                FileInputStream  fis = new FileInputStream("双元.jpg");
                FileOutputStream  fos = new FileOutputStream("copy.jpg");
                int len;
                byte[] arr = new byte[1024 * 8];                                        //自定义字节数组
               
                while((len = fis.read(arr)) != -1) {
                       
                        fos.write(arr, 0, len);                                                        //写出字节数组写出有效个字节个数
                }
               
                fis.close();
                fos.close();
        }

}

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马