您的位置:首页 > 其它

第四篇学习笔记

2016-04-08 20:50 417 查看
import java.io.*;

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


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: