//字符缓冲流主要用于文本数据的高速写入
package cn.lijun.demo1; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; public class BufferedReaderDemo { public static void main(String[] args) throws Exception { //创建字符输入缓冲流对象 BufferedReader bf=new BufferedReader(new FileReader("d:\\b.txt")); String len=null; while((len=bf.readLine())!=null){ System.out.println(len); } bf.close(); } } //字节输出缓冲流 package cn.lijun.demo1; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; public class BufferedWriterDemo { public static void main(String[] args) throws IOException { //创建字符输出流 封装文件 FileWriter fw=new FileWriter("d:\\b.txt"); BufferedWriter bw = new BufferedWriter(fw); bw.write("您好"); bw.newLine(); //换行 bw.write(100); bw.flush(); bw.write("adasfdsf"); bw.close(); } }
原文地址:https://www.cnblogs.com/qurui1998/p/10602725.html
时间: 2024-10-08 02:12:09