Java第四次实验

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;


public class Test {public static void TestfileQuick(File filein, File fileout) throws IOException{
    FileInputStream in = new FileInputStream(filein);
    FileOutputStream out = new FileOutputStream(fileout);
    byte[] buf=new byte[8*1024];
    int b;
    while((b=in.read( buf, 0, buf.length))!=-1){
        out.write(buf, 0, b);
    }
    in.close();
    out.close();
}

public static void main(String[] args){
    try{
        long start = System.currentTimeMillis();
        Test.TestfileQuick(new File("C:\\Users\\Administrator\\Desktop\\尧十三 - 牧羊曲(Demo).mp3"), 
                             new File("C:\\Users\\Administrator\\Desktop\\1.mp3"));
        long end = System.currentTimeMillis();
        System.out.println("时间:" + (end - start));
    }catch(IOException e){
        e.printStackTrace();
    }
}
}

posted @ 2016-04-08 20:15  Gentleman`  阅读(214)  评论(0编辑  收藏  举报