public?static?void?iprByCharArray(File?file)?throws?IOException?{
????if(!file.exists()){
????????throw?new?IllegalArgumentException("文件不存在");
????}
????if(!file.isFile()){
????????throw?new?IllegalArgumentException("不是文件");
????}
????FileInputStream?in=new?FileInputStream(file);
????InputStreamReader?ipr=new?InputStreamReader(in);
????int?c;
????char[]?chars=new?char[2*1024];
????System.out.println("字符流批量讀取");
????while?((c=ipr.read(chars,0,chars.length))!=(-1)){
????????System.out.print(chars);
????}
}
2020-06-21
樓上+1
2019-09-27
字符流,讀出來是個字符啊,一串字符不就是字符串了嗎