zoukankan      html  css  js  c++  java
  • import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;

    public class CopyFile {

     /**
      * @param args
      */
     public static void copy(File a,File b){
      try {
       FileInputStream fis = new FileInputStream("a.mp3");
       FileOutputStream fos = new FileOutputStream("temp.mp3");
        //改进方法代码
       byte[] buf = new byte[2008];
       int length;
       int read = fis.read();
       while((length = fis.read(buf))!=-1){
        fos.write(buf, 0, length);
       //
       }
       fis.close();
       fos.close();
      } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      }
     }
     public static void main(String[] args) {
      // TODO Auto-generated method stub
      //测试时间代码
      File a = new File("");
      File b = new File("");
      long start,end;
      start = System.currentTimeMillis();
      copy(a,b);
      end = System.currentTimeMillis();
      System.out.println("用时:" + (end - start) + "ms");
     //
     }
    }

  • 相关阅读:
    poj 3422 Kaka's Matrix Travels
    poj 1815 Friendship
    poj 1966 Cable TV Network
    黑暗
    【bzoj2741】[FOTILE模拟赛] L
    整数拆分
    LCIS
    原题的旅行
    【codeforces gym】Increasing Costs
    【noip模拟】D(==)
  • 原文地址:https://www.cnblogs.com/abaibjw12345/p/5369912.html
Copyright © 2011-2022 走看看