package IO;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class copyFile {
public static void main(String[] args) {
long t1 = System.currentTimeMillis();
copyimg("e:/刺绣.jpg","e:/2.jpg");
long t2 = System.currentTimeMillis();
System.out.println(t2-t1);
}
public static void copyimg(String source,String it){
try(FileInputStream in=new FileInputStream(source);
FileOutputStream out=new FileOutputStream(it)) {
//创建字节缓冲区
byte[] buffer=new byte[1024];
int temp=0;
while ((temp=in.read(buffer))!=-1){
out.write(buffer,0,temp);
}
out.flush();
}catch (Exception e){
e.printStackTrace();
}
}
}
第一个是要复制的文件路径,第二个是复制后指定地址和名称