阅读背景:

使用BufferedInputStream和BufferedOutputStream实现非文本文件的复制_SleepWalkGod的博客

来源:互联网 
public void test() {

        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        try {
            //1.造文件
            File srcfile = new File("图片.JPG");
            File destfile = new File("图片1.JPG");
            //2.造流
              //造节点流
            FileInputStream fis = new FileInputStream(srcfile);
            FileOutputStream fos = new FileOutputStream(destfile);
              //造处理流---->缓冲流
            bis = new BufferedInputStream(fis);
            bos = new BufferedOutputStream(fos);

            //3.复制操作:读取、写入
            byte[] buffer = new byte[10];
            int len;
            while ((len = bis.read(buffer)) != -1){
                bos.write(buffer,0,len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            //4.关闭流
            if (bis != null){
                try {
                    bis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (bos != null){
                try {
                    bos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }public void test() {

        BufferedInputStre



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: