try {
//字节流读写文件
FileReader fr = new FileReader("test.txt"); BufferedReader br = new BufferedReader(fr); FileWriter fw = new FileWriter("testw.txt"); BufferedWriter bw = new BufferedWriter(fw); String line; while ((line = br.readLine()) != null) { bw.write(line + "\n"); } bw.flush();//强制缓冲区输出 bw.close(); fw.close(); br.close(); fr.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }