File.io讀取文件(一)

public class FileRead01 {
/**
* 文件-(I流)--》程序
* @param args
* @throws IOException 
*/
public static void main(String[] args) throws IOException {
//1,建立文件與程序的聯繫
File f=new File("D:/a.txt");
//2,選擇流
InputStream is=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();
}
}
發佈了30 篇原創文章 · 獲贊 1 · 訪問量 6188
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章