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[1444];
    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");
    //
    }

    }

  • 相关阅读:
    模拟测试48
    模拟测试47
    模拟测试46
    NOIP模拟测试29(A)
    NOIP模拟测试19
    NOIP模拟测试18(T3待更新)
    杂题
    noip模拟测试18 T2搜索
    noip模拟测试17 2019-08-11 考后反思
    noip模拟测试14 20190807 考试反思
  • 原文地址:https://www.cnblogs.com/javamenwaihan/p/5369877.html
Copyright © 2011-2022 走看看