forked from 0xrumble/BytecodeScreen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirUtil.java
More file actions
55 lines (46 loc) · 1.4 KB
/
DirUtil.java
File metadata and controls
55 lines (46 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package tools;
import org.slf4j.Logger;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class DirUtil {
private static Logger logger;
private static final List<String> filenames = new ArrayList<>();
public static List<String> GetFiles(String path) {
filenames.clear();
return getFiles(path);
}
private static List<String> getFiles(String path) {
File file = new File(path);
if (file.isDirectory()) {
File[] files = file.listFiles();
if (files == null) {
return filenames;
}
for (File value : files) {
if (value.isDirectory()) {
getFiles(value.getPath());
} else {
filenames.add(value.getAbsolutePath());
}
}
} else {
filenames.add(file.getAbsolutePath());
}
return filenames;
}
public static boolean removeDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
if (children != null) {
for (String child : children) {
boolean success = removeDir(new File(dir, child));
if (!success) {
return false;
}
}
}
}
return dir.delete();
}
}