public static void testBuffer() throws IOException { BufferedReader bufferedReader = new BufferedReader(new FileReader("C:\\test.txt")); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("E:\\test.txt")); String x; while ((x = bufferedReader.readLine()) != null) { bufferedWriter.write(x+"\n"); System.out.println(x); } bufferedWriter.flush(); bufferedWriter.close(); bufferedReader.close(); }