import java.io.*;
public class CopyTextByBuff {
public static void main(String[] args ) throws IOException{
BufferedReader bufr = null;
BufferedWriter bufwr = null;
FileReader a = new FileReader("c:\\123.txt");
bufr = new BufferedReader( a );
FileWriter b = new FileWriter("c:\\1234.txt",true);
bufwr = new BufferedWriter(/*new FileWriter("c:\\1234.txt")*/b);
String line = null;
while((line = bufr.readLine())!=null){
bufwr.write(line);
bufwr.newLine();
前面我就不说了,先后顺序一目了然。
将b.write()与flush换一下位置的话,按我理解就是你没刷新的话,数据都还放在缓冲区里,然后你先b.write("你好"),而b所直接操作的是
new FileWriter("c:\\1234.txt",true);也就是说后面刷新的时候"你好"先一步被刷进文件里了,"你好"就跑到前头了