文件复制

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

//文件的复制
public class Demo03Copy {
    public static void main(String[] args) throws IOException {
        FileInputStream fis=new FileInputStream("F:\\basic\\untitled13\\src\\it\\cast\\day15\\demo01\\1.txt");
        FileOutputStream fos=new FileOutputStream("F:\\basic\\untitled13\\src\\it\\cast\\day15\\demo01\\3.txt");
        byte[] bytes1=new byte[1024];
        int len=0;
        while ((len=fis.read(bytes1))!=-1){
            //System.out.println(new String(bytes1,0,len));//读取有效的几个
            fos.write(bytes1,0,len);
        }
    }
}

 

posted @ 2020-10-06 17:34  159566  阅读(123)  评论(0编辑  收藏  举报