字节流实现文件的复制

FileInputStream file1 = new FileInputStream("E:/abc/hello.txt");
        FileOutputStream file2 = new FileOutputStream("E:/cba/hello.txt");
        int i = 0;
        while((i = file1.read())!=-1){
            file2.write(i);
        }
        file1.close();
        file2.close();
        
        FileInputStream file3 = new FileInputStream("E:/cba/hello.txt");
        
        int y = 0;
        while((y = file3.read())!=-1){
            System.out.println((char)y);
        }
        file3.close();

 

posted @ 2021-12-10 09:22  無zz  阅读(45)  评论(0)    收藏  举报