FileOutputStream write与原文件md5不一致,文件变大了

来源:互联网 发布:定时发送短信软件 编辑:程序博客网 时间:2024/06/12 00:56
原代码:
            FileInputStream fis = new FileInputStream(source);            FileOutputStream fos = new FileOutputStream(target);            byte[] bts = new byte[300];            while (fis.read(bts, 0, 300) != -1) {                fos.write(bts, 0, 300);            }            fos.close();            fis.close();


更改后代码

            FileInputStream fis = new FileInputStream(source);            FileOutputStream fos = new FileOutputStream(target);            byte[] bts = new byte[300];            int len=-1;            while ((len=fis.read(bts)) != -1) {                fos.write(bts, 0, len); //更改处            }            fos.close();            fis.close();


0 0