字节流高效缓冲区文件复制

    public static void fileCopy2BufferByte(String oldFileName,String newFileName){
        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        try{
            bis = new BufferedInputStream(new FileInputStream(oldFileName));
            bos = new BufferedOutputStream(new FileOutputStream(newFileName));
            byte[] bytes = new byte[1024];
            int len = -1;
            while ((len = bis.read(bytes))!=-1)bos.write(bytes,0,len);
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            try {
                if(bis!=null)bis.close();
                if(bos!=null)bos.close();
            }catch (IOException ee){
                ee.printStackTrace();
            }
        }
    }

 

posted @ 2018-03-11 08:32  静赋清承  阅读(238)  评论(0编辑  收藏  举报