package com.ylh4Y4;
//字节流读数据一次读一个字节数组的数据
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
//字节流读数据
public class read {
public static void main(String[] args) throws IOException {
FileInputStream fis=new FileInputStream("E:\\java\\myhomework\\源文件.txt");
//第一次遍历
byte[] by=new byte[5];
int len= fis.read(by);
System.out.println(len);
System.out.println(new String(by));
// hello/r/n
// world/r/n
//第二次遍历
len= fis.read(by);
System.out.println(len);
System.out.println(new String(by));
//循环改进
// byte[]by=new byte[1024];
// int len;
// while((len=fis.read(by))!=-1){
// System.out.print(new String(by,0,len));
//
// }
// fis.close();
}
}