import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class CopyTextByBufferTest {
public static void main(String[] args) throws IOException {
FileReader fr =new FileReader("demo.txt");
BufferedReader bufr = new BufferedReader(fr);
FileWriter fw =new FileWriter("copy.txt");
BufferedWriter bufw = new BufferedWriter(fw);
String line = null;
while ((line = bufr.readLine()) != null) {
bufw.write(line);
bufw.newLine();
bufw.flush();
}
}
}
-----------------------------------------------------------------------------------------------------------------------------------------------
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class CopyTextByBufferTest {
public static void main(String[] args) throws IOException {
FileReader fr = null;
BufferedReader bufr = null;
FileWriter fw = null;
BufferedWriter bufw = null;
fr = new FileReader("demo.txt");
bufr = new BufferedReader(fr);
fw = new FileWriter("copy.txt");
bufw = new BufferedWriter(fw);
String line = null;
while ((line = bufr.readLine()) != null) {
bufw.write(line);
bufw.newLine();
bufw.flush();
}
}
} |