📜  java 读取目录 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:31.388000             🧑  作者: Mango

代码示例1
public void listFilesForFolder(final File folder) {
    for (final File fileEntry : folder.listFiles()) {
        if (fileEntry.isDirectory()) {
            listFilesForFolder(fileEntry);
        } else {
            System.out.println(fileEntry.getName());
        }
    }
}

final File folder = new File("/home/you/Desktop");
listFilesForFolder(folder);