JAVA日志
第四篇
指定文件的复制
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Ctrlc {
public static void main(String []args){
long startTime = System.nanoTime();//得到程序开始时间
try {
FileInputStream fis =new FileInputStream("a.mp3");
FileOutputStream fos =new FileOutputStream("a4.mp3");
int read=fis.read();
byte[] buf = new byte[200000];
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();
}
long endTime = System.nanoTime();
System.out.println("复制用时:"+(endTime-startTime)+"纳秒");
}
}