//BufferedWriter类 BufferedReader类(实现文件的复制) package work; import java.io.*; public class writer { public static void main(String[] args) throws IOException { //输入流缓冲区 BufferedReader hr = new BufferedReader(new FileReader("H:\\log.txt")); //输出流缓冲区 BufferedWriter hm = new BufferedWriter(new FileWriter("H:\\red.txt")); String line; while ((line = hr.readLine()) != null){如果还有下一行就一直读下去readLine()用于读取一行 hm.write(line);//写入hm中 hm.newLine();//换行符 hm.flush();//刷新 } //关闭 节约资源 hr.close(); hm.close(); } }
//BufferedWriter类 BufferedReader类(实现文件的复制)
于 2022-04-14 15:18:31 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)