像下面的代码:
import java.io.*;
class FileWriterDemo
{
public static void main(String[] args)
{
FileWriter fw = null ;
FileReader fr = null ;
BufferedReader bufr = null;
BufferedWriter bufw = null;
char[] buf = new char[1024];
int num = 0;
try
{
fw = new FileWriter("wifi.txt");
fr = new FileReader("BufferedWriterDemo.java");
bufr = new BufferedReader(fr);
bufw = new BufferedWriter(fw);
fw.write("abc");
fw.flush();
String line = null;
while((line = bufr.readLine())!=null)
{
bufw.write(line);
bufw.newLine();
bufw.flush();
System.out.println(line);
}
System.out.println("aa");
while((line = bufr.readLine()) != null)
{
System.out.println(line);
}
}
catch(IOException e)
{
System.out.println(e.toString());
}
finally
{
if(bufw != null)
try
{
fw.close();
}
catch(IOException e)
{
System.out.println(e.toString());
}
if(bufr != null)
try
{
fr.close();
}
catch(IOException e)
{
System.out.println(e.toString());
}
}
}
}
带颜色的这段为什么又没执行到的?
控制台的打印结果只有:aa。
文本copy到了,就是没有打印到控制台上,是不是缓冲区只能用一次啊??
|
|