代码如下:
package CopyJavaPack01;import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;public class CopyJavaDemo04 {public static void main(String[] args) throws IOException {BufferedWriter bw = new BufferedWriter(new FileWriter("D:\\JavaDemo\\bw.txt"));for (int i = 0;i<10;i++){bw.write("hello"+i);bw.newLine();bw.flush();}bw.close();}}
package CopyJavaPack01;import java.io.*;public class CopyJavaDemo04 {public static void main(String[] args) throws IOException {BufferedReader br = new BufferedReader(new FileReader("D:\\JavaDemo\\java.txt"));String line;while((line=br.readLine())!=null){System.out.println(line);}br.close();}}