package demo;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class A5 {
public static void main(String[] args) throws IOException {
String a = "D:\\金山打字";
String b = "D:\\银山打字";
copy1(a, b);
}
public static void copy1(String a, String b) throws IOException {
copy2(new File(a), new File(b));
}
public static void copy2(File file, File file1) throws IOException {
if (!file1.exists()) {
file1.mkdirs();
}
if (file.isDirectory()) {
File[] files = file.listFiles();
for (File file2 : files) {
if (file2.isDirectory()) {
copy2(file2, new File(file1.getPath(), file2.getName()));
} else {
Files.copy(file2.toPath(), Paths.get(file1.getPath() + "\\" + file2.getName()));
}
}
}
}
}