标签:字符缓冲流 sys 读取 字符 count demo1 ase reader imp
package com.sean.base.streamStudy; import java.io.BufferedReader; import java.io.FileReader; /** * 使用字符缓冲流读取文件 * @create 2021-02-26 14:28 */ public class Demo11 { public static void main(String[] args)throws Exception { //创建缓冲流 FileReader fr = new FileReader("d:\\write.txt"); BufferedReader br = new BufferedReader(fr); //2读取 //2.1第一种方式 /*char[] buf=new char[1024]; int count =0; while ((count=br.read(buf))!=-1){ System.out.println(new String(buf,0,count)); }*/ //2.2第二种方式,一行一行的读取 String line =null; while ((line=br.readLine())!=null){ System.out.println(line); } //3关闭 br.close(); } }
标签:字符缓冲流 sys 读取 字符 count demo1 ase reader imp
原文地址:https://www.cnblogs.com/guangenpu/p/14452211.html