-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
34 lines (26 loc) · 905 Bytes
/
Main.java
File metadata and controls
34 lines (26 loc) · 905 Bytes
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
import java.io.File;
public class Files {
public static void main(String[] args) {
// Replace --F-- to disk name like: C:// F:// D:// E:// P://
String path = "F:\\";
File directory = new File(path);
File[] fileList = directory.listFiles();
for (File file : fileList) {
if (file != null && file.isDirectory()) {
System.out.println("Directory: " + file.getName());
listFolders(file);
}
}
}
public static void listFolders(File directory) {
File[] fileList = directory.listFiles();
if (fileList != null) {
for (File file : fileList) {
if (file != null && file.isDirectory()) {
System.out.println("Directory: " + file.getName());
listFolders(file);
}
}
}
}
}