IO部分细节重新整理


利用两天时间再回顾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));
		}
	}
}


 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章