字节流文件的复制

阅读 87

2022-03-19

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)

0 0 举报