0
点赞
收藏
分享

微信扫一扫

字节流文件的复制

山竹山竹px 2022-03-19 阅读 86
java
public class Demo03 {
    //字节流的练习:文件复制  先input读 再output写
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("D:\\01.bmp");
        FileOutputStream fos = new FileOutputStream("D:\\0001.bmp");
        int len=0;
       while((len=fis.read())!=-1){
           fos.write(len);
       }
       fis.close();
       fos.close();
    }
    }
public class Demo03 {
    //字节流的练习:文件复制  先input读 再output写
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("D:\\01.bmp");
        FileOutputStream fos = new FileOutputStream("D:\\00001.bmp");
        byte[] bytes = new byte[1024];
        int len=0;
       while((len=fis.read(bytes))!=-1){
           fos.write(bytes,0,len);
       }
       fis.close();
       fos.close();
    }
    }
举报

相关推荐

0 条评论