利用兩天時間再回顧IO細節。
牢記老畢的名言,捷徑就是敲,狂敲!
public class FileReaderDemo2 {
public static void main(String[] args) throws Exception{
FileReader fr = new FileReader("C:\\Demo.java");
char[] buf = new char[1024];//一個字符兩個字節,所以該字符數組長度 是2k
//read(buf)返回的是讀到的字符的個數
while(fr.read(buf)!=-1){
//System.out.println(new String(buf,0,chs.length));
//第二種方式
System.out.println(String.valueOf(buf,0,buf.length));
}
}
}