package com.heima.test;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class Test3 {
/**
定义一个文件输入流,调用 read(byte[] b)方法将 exercise.txt 文件中的所有内容打印出来
(byte 数组的大小限制为 5)。
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
FileInputStream fis = new FileInputStream("aaa.txt");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int len;
byte[] b = new byte[5];
while((len = fis.read(b)) != -1){
baos.write(b,0,len);
}
System.out.println(baos);
}
}