- import java.io.*;
- public class BufferedWriterDemo
- {
- public static void main(String[] args)
- {
- FileWriter fw=null;
- BufferedWriter bf=null;
- try
- {
- fw=new FileWriter("D:\\bfDemo.txt");
- bf=new BufferedWriter(fw);
- for(int x=0;x<4;x++)
- {
- bf.write("abcd");
- bf.newLine();
- }
- bf.flush();
-
- }
- catch(IOException e)
- {
-
- }
- finally
- {
- try{
- bf.close();
- }
- catch(IOException e)
- {
-
- }
- }
- }
- }
复制代码 这边一定要flush缓冲区吗? |