package com.io.liushuaishuai; import java.io.*; public class copyjavaDemo01 { public static void main(String[] args) throws IOException { //创建字符缓冲输入流对象 BufferedReader br = new BufferedReader(new FileReader("C:\Users\86132\IdeaProjects\javaSE_Code\myIOstream\src\com\io\liushuaishuai\StringDemo.java")); //创建字符缓冲流输出流对象 BufferedWriter bw = new BufferedWriter(new FileWriter("myIOstream\copy02.java")); //一次读取一个字符 // int i; // while ((i = br.read()) != -1) { // bw.write(i); // } // 一次读取一个字符数组 char[] ch = new char[1024]; int len; while ((len = br.read(ch)) != -1) { bw.write(ch, 0, len); } //释放资源 bw.close(); br.close(); } }