zoukankan      html  css  js  c++  java
  • Java基础之IO流,通过字节流缓冲区进行媒体文件的复制操作

    import java.io.*;

    class BufferedCopyFileDemo
    {
        public static void main(String[] args)throws IOException
        {
            BufferedInputStream bis = null;
            BufferedOutputStream bos = null;
        
            try
            {
                bis = new BufferedInputStream(new FileInputStream(new File("001.avi")));
                bos = new BufferedOutputStream(new FileOutputStream(new File("001-1.avi")));
                
                int ch = 0;
                while((ch=bis.read())!=-1)
                {
                    bos.write(ch);
                }            
            }
            catch(IOException e)
            {
                System.err.println(e.getMessage());
            }
            finally
            {
                try            
                {
                    if(null!=bis)bis.close();
                    if(null!=bos)bos.close();
                }
                catch(IOException e)
                {
                    System.err.println(e.getMessage());
                }
            }
        }
    }
  • 相关阅读:
    Split Temporary Variable
    Introduce Explaining Variable
    Replace Temp with Query
    Extract Method
    自测代码的价值
    代码的坏味道
    Divergent Change & Shotgun Surgery
    Large Class
    Long Method
    Duplicated Code
  • 原文地址:https://www.cnblogs.com/cxmsky/p/2886936.html
Copyright © 2011-2022 走看看