File.io读取文件(二)

来源:互联网 发布:java messagequeue 编辑:程序博客网 时间:2024/06/05 21:50
public class FileRead2 {
/**
* 文件-(I流+缓冲流)--》程序
* 缓冲流提高性能
* @throws IOException 
*/
public static void main(String[] args) throws IOException {

//1,建立文件与程序的联系
File f=new File("D:/a.txt");
//2,选择流
BufferedInputStream/*InputStream*/ is=new BufferedInputStream(
new FileInputStream(f));
//3,操作数据
byte[] flush=new byte[31/*1024*/];
int len=0;
while(-1!=(len=is.read(flush))){
System.err.println("在这里进行数据处理"+len+"字节:"+Arrays.toString(flush));
}
is.close();
}
}
0 0
原创粉丝点击