大家好,欢迎来到IT知识分享网。
package ba;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
public class huancunTest {
/**
* @param args
*/
public static void main(String[] args) {
Date d1=new Date();
Date d2=new Date();
long l1=d1.getTime();
copy("G:/a.png","G:/test/a.png");
long l2=d2.getTime();
System.out.println(l2-l1);
}
public static void copy(String str,String des){
File srcFile = new File(str);
File desFile = new File(des);
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream(srcFile));
bos = new BufferedOutputStream(new FileOutputStream(desFile));
byte[]b=new byte[1024];
int len=0;
try {
while((len=bis.read(b))>0){
bos.write(b,0,len);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(bis!=null){
try {
bis.close();
bos.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/31945.html
