IO流-小数组读取

package com.day17.IO;

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

public class ArrayCopyStandard {

  public static void main(String[] args) throws IOException {
    FileInputStream fis=new FileInputStream("桌面背景.jpg");
    FileOutputStream fos=new FileOutputStream("桌面背景copy.jpg");
    byte[] arr=new byte[1024*8];//创建两个字节的数组
    int len;
    while((len=fis.read(arr))!=-1) {//这是两个两个字节的度,比原来的快一倍
      fos.write(arr,0,len);//从0索引处开始写,长度为len
    }
    fis.close();
    fos.close();
  }

}

posted @ 2018-06-03 16:44  简简单单zjl  阅读(653)  评论(0编辑  收藏  举报