MCPcopy Create free account
hub / github.com/XUANXUQAQ/File-Engine / copyDir

Method copyDir

src/main/java/file/engine/utils/file/FileUtil.java:90–111  ·  view source on GitHub ↗
(String sourcePath, String newPath)

Source from the content-addressed store, hash-verified

88 }
89
90 public static void copyDir(String sourcePath, String newPath) {
91 File source = new File(sourcePath);
92 File dest = new File(newPath);
93 String[] filePath = source.list();
94 //获取该文件夹下的所有文件以及目录的名字
95 if (filePath == null || filePath.length == 0) {
96 return;
97 }
98 if (!dest.exists()) {
99 dest.mkdirs();
100 }
101 for (String temp : filePath) {
102 //查看其数组中每一个是文件还是文件夹
103 if (isDir(sourcePath + File.separator + temp)) {
104 //为文件夹,进行递归
105 copyDir(sourcePath + File.separator + temp, newPath + File.separator + temp);
106 } else {
107 //为文件则进行拷贝
108 copyFile(new File(sourcePath + File.separator + temp), new File(newPath + File.separator + temp));
109 }
110 }
111 }
112}

Callers 1

mainMethod · 0.95

Calls 2

isDirMethod · 0.95
copyFileMethod · 0.95

Tested by

no test coverage detected