import java.io.*;
//字符流
public class Demo02 {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(new FileInputStream(new File("D:\\develop\\IdeaProjects\\employ\\idea_demo\\src\\Day01\\itheima_01\\Demo.java")));
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(new File("idea_demo\\copy.java")));
/* //字符输入流、字符输出流完成对文件的复制(一次读取、写入一个字符数组)
char[]chs = new char[1024];
int len;
while ((len =isr.read(chs))!=-1){
osw.write(chs,0,len);
}
isr.close();
osw.close();*/
//字符输入流、字符输出流完成对文件的复制(一次读取、写入一个字符)
int len;
while ((len = isr.read()) != -1) {
osw.write(len);
}
isr.close();
osw.close();
}
}
字符流的代码格式之两种复制方式
最新推荐文章于 2022-09-23 21:16:35 发布