标签:inf for nbsp info load input 图片 bytes targe
1 public class copy{ 2 public static void main(String args[]){ 3 File sourse=new File("d:/123456789"); 4 File target=new File("d:/987654321"); 5 method(sourse,target); 6 } 7 8 public static void method(File sourse,File target){
if(target.isFile()){
copyFile(sourse,target);
}
9 if(!target.isexists()){ 10 target.mkdir(); 11 }15 File[] files=sourse.listFile(); 16 for(File file : files){ 17 method(file,new File(target,file.getName())); 18 } 19 20 public static void copyFile(File sourse,File target){ 21 InputStream in=new FileInputStream(sourse); 22 OutputStream out-new FileOutputStream(target); 23 byte[] bytes=new byte[1024]; 24 int temp=0; 25 while((temp=in.read(bytes))!=-1){ 26 out.write(bytes,0,temp); 28 in.close(); 29 out.close(); 30 } 32 } 33 } 34 }
标签:inf for nbsp info load input 图片 bytes targe
原文地址:https://www.cnblogs.com/520-hahaha/p/13232901.html