package package3;
import java.io.*;
public class CopyJavaDemo1 {
public static void main(String[] args) throws IOException {
//根据数据源创建字符字符缓冲输入流对象
BufferedReader br =new BufferedReader(new FileReader("day04\\fos.txt"));
//根据目的地创建字符缓冲输出流对象
BufferedWriter bw =new BufferedWriter(new FileWriter("day04\\Copy.txt"));
//一次读写一个字符数据
// int ch;
// while ((ch=br.read())!=-1){
// bw.write(ch);
// }
//读写数据,复制文件
//一次读写一个字符数组数据
int len;
char[] arr =new char[1024];
while ((len=br.read(arr))!=-1){
bw.write(arr,0,len);
}
//释放资源
bw.close();
br.close();
}
}
标签:字符,arr,Java,缓冲,bw,br,new
From: https://www.cnblogs.com/knlf/p/16813590.html