zoukankan      html  css  js  c++  java
  • java文件读写操作

    private static final int BUFFER_SIZE = 256 * 1024 ;

    try {

       InputStream in=null;

      OutputStream out=null;

      try{

        in=new BufferedInputStream(new FileInputStream(src),Buffer_size);

       out=new BufferedInputStream(new FileOutputStream(dst),Buffer_size);

        int srcfilesize=in.available();

       byte[] buffer=new byte[srcfilesize>BUFFER_SIZE?BUFFER_SIZE:srcfilesize];

       while (in.read(buffer)>0){

           out.write(buffer);

          if (srcfilesize>BUFFER_SIZE){

               srcfilesize=srcfilesize-buffer_size;

               buffer=new byte[srcfilesize>buffer_size?buffer_size:srcfilesize];

           }

      }

    }finally{

        if (null!=in){

          in.close();

    }

      if (null!=out){

        out.close();

    }

    }catch(Exception e){

       e.printstacktrace();

    }

    }

    }

  • 相关阅读:
    centos 研究
    python学习6 web开发
    python学习5 常用三方模块
    python学习4 常用内置模块
    python学习 3笔记
    SQLite
    mysql
    python学习 2数学公式
    python学习 1基础
    shell example02
  • 原文地址:https://www.cnblogs.com/wjlstation/p/2913941.html
Copyright © 2011-2022 走看看