java实现文件复制
public class TestIO {
public static void main(String[] args) throws IOException {
long s=System.currentTimeMillis();
FileInputStream fis=new FileInputStream("C:\\Users\\Administrator\\Desktop\\Study\\2.jpg");//数据源
FileOutputStream fos=new FileOutputStream("C:\\Users\\Administrator\\Desktop\\Study\\src\\com\\bainan\\io\\2.jpg");//目的地路径
byte[] bytes=new byte[1024];
int len=0;
while ((len=fis.read(bytes))!=-1){
fos.write(bytes);
}
//释放资源(先关写的,再关闭读的)
fos.close();
fis.close();
long b=System.currentTimeMillis();
}
}