字节流复制Java文件

package com.czie.iot1913.lps.IO.OutpurStream;

import java.io.*;

/**
* FileName: CopyJavaDemo
* Author: lps
* Date: 2022/3/26 14:50
* Sign:刘品水 Q:1944900433
*/
public class CopyJavaDemo {
public static void main(String[] args) throws IOException {
InputStreamReader isr = new InputStreamReader(new FileInputStream("F:\\JavaCode\\ConversionStreamDemo.java"));

OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("F:\\JavaCode\\Copy.java"));

char[] chars = new char[1024];
int len;
while((len=isr.read(chars))!=-1){
//System.out.println(new String(chars,0,len));
osw.write(chars,0,len);
}
isr.close();
osw.close();


}
}

 

posted @ 2022-03-26 15:03  刘品水  阅读(21)  评论(0编辑  收藏  举报