int read(byte[] b):一次读取一个字节数组,这个的执行效率远远高于第一种方式
public class FileInputStreamDemo2 {
public static void main(String[] args) throws IOException {
//创建一个文件字节输入流对象
FileInputStream fis=new FileInputStream("fis2.txt");
byte[] buffer=new byte[1024];
int len=0;
while((len=fis.read(buffer))!=-1) {
System.out.println(new String(buffer,0,len));
}
//释放资源
fis.close();
}
}