当前位置:   article > 正文

//BufferedInputStream BufferedOutputStream类(实现文件的复制)_bufferedinputstream 深拷贝

bufferedinputstream 深拷贝
//BufferedInputStream  BufferedOutputStream类(实现文件的复制)
package work;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class stream {
    public static void main(String[] args) {
        BufferedInputStream br = null;
        BufferedOutputStream bm = null;
        try {
           br  = new BufferedInputStream(new FileInputStream("H:\\a.txt"));
           bm  = new BufferedOutputStream(new FileOutputStream("H:\\log.txt"));
           int l = 0;
           byte[] b = new byte[1024];
           while ((l = br.read(b))!=-1){
               bm.write(b);
               bm.flush();
               System.out.println("复制成功");
           }
           br.close();
           bm.close();
        } catch (Exception e) {
            e.printStackTrace();
        }


    }

}
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/146928
推荐阅读
相关标签
  

闽ICP备14008679号