import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
/*
* 字符输出流缓冲区流 java.io.BufferedWriter,继承Writer
* 写入方法write() 单个字符,字符数组,字符串
* 构造方法:
* BufferedWriter(Writer w)传递任意字符输出流
* 传递谁,就高效谁
* BufferedWriter具有自己特有的方法:
* void newLine():写换行 \r\n也是文本换行
*/
public class BufferedWriterDemo {
public static void main(String[] args) throws IOException{
//创建字符输出流,封装文件
FileWriter fw=new FileWriter("d:\\demo\\c.txt");
BufferedWriter bfw=new BufferedWriter(fw);
/*bfw.write(100);
bfw.flush();
bfw.write("你好".toCharArray());
bfw.flush();*/
bfw.write("你好\r\n");
bfw.flush();
bfw.write("我好");
bfw.newLine();
bfw.flush();
bfw.write("大家都好");
bfw.flush();
bfw.close();
}
}
import java.io.FileWriter;
import java.io.IOException;
/*
* 字符输出流缓冲区流 java.io.BufferedWriter,继承Writer
* 写入方法write() 单个字符,字符数组,字符串
* 构造方法:
* BufferedWriter(Writer w)传递任意字符输出流
* 传递谁,就高效谁
* BufferedWriter具有自己特有的方法:
* void newLine():写换行 \r\n也是文本换行
*/
public class BufferedWriterDemo {
public static void main(String[] args) throws IOException{
//创建字符输出流,封装文件
FileWriter fw=new FileWriter("d:\\demo\\c.txt");
BufferedWriter bfw=new BufferedWriter(fw);
/*bfw.write(100);
bfw.flush();
bfw.write("你好".toCharArray());
bfw.flush();*/
bfw.write("你好\r\n");
bfw.flush();
bfw.write("我好");
bfw.newLine();
bfw.flush();
bfw.write("大家都好");
bfw.flush();
bfw.close();
}
}