第四次作业

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class Copyfile {
long time=System.currentTimeMillis();
public void copy(){
try { 
FileInputStream fis =new FileInputStream("a.mp3");
FileOutputStream fos =new FileOutputStream("w.mp3");
byte[] buf = new byte[1024*1000];
int len = 0 ;
while((len=fis.read(buf)) != -1){
fos.write(buf,0,len);
}
fis.close();
fos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("执行耗时 : "+(System.currentTimeMillis()-time)/1000f+" 秒 ");
}
public static void main(String []args){
Copyfile a= new Copyfile();
a.copy();
}
}

posted @ 2016-04-10 19:34  涛。  阅读(112)  评论(0编辑  收藏  举报