1.在e盘下创建aaa.txt文件
2.代码
代码语言:javascript
复制package d01_TestInput;/*
* zt
* 2020/8/7
* 10:33
*
*/
import java.io.FileInputStream;
public class Test1 {
public static void main(String[] args) throws Exception {
FileInputStream fis = new FileInputStream("e:\aaa.txt");
byte[] buf = new byte[1024];
int len=0;
/*len = fis.read(buf);
System.out.println(new String(buf,0,len));
len = fis.read(buf);
System.out.println(new String(buf,0,len));*/
while((len = fis.read(buf))!=-1){
System.out.println(new String(buf,0,len));
}
fis.close();
}
}
3.运行结果
代码语言:javascript
复制大大师傅?呱?i love you