public class Main {
public static void main(String[] args) {
new CopyFiles().copy("d://jlx", "e:");
System.out.println("复制完成!");
}
}
第二个
package review;
import java.io.File;
public class CopyFiles {
public void copy(String URLFile,String newFile){
File f1=new File(URLFile);
if(f1.isDirectory())
{
newFile=newFile+f1.getName();
new File(newFile).mkdir();
File[] URL=f1.listFiles();
for(File name:URL)
{
File f2=new File(name.toString());
if(f2.isDirectory())
{
copy(f2.getPath(),newFile+"//");
}
else{
new CopyFile().copy(f2.getPath(), newFile+"//"+f2.getName());
}
}
}
else{
new CopyFile().copy(f1.getPath(), newFile+f1.getName());
}
}
}
第三个