s-day09-文件复制的分析与实现(两种方式)
This commit is contained in:
@@ -36,6 +36,12 @@ public class Demo07 {
|
||||
|
||||
byte[] bytes = new byte[1024];//用来保存字节输入流读取到的字节数据
|
||||
int len;//用来接收读取到的字节数据的个数,如果返回-1表示读取到末尾了
|
||||
/*
|
||||
((len = fis.read(arr))!= -1)执行流程:
|
||||
1.is.read(arr) :从字节输入流中最多读取数组长度的字节数据保存在数组中,返回读取到的字节的数量
|
||||
2.len = fis.read(arr):返回读取到的字节的数量保存到变量len中
|
||||
3.(len = fis.read(arr))!= -1:判断是否读取到字节数据的数量,如果读取到,那么就获取多少个字节数据,如果没有-1则结束循环
|
||||
*/
|
||||
while ((len = fis.read(bytes)) != -1) {//(核心代码)
|
||||
System.out.println(new String(bytes,0,len));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user