📜  检查文件夹中的文件 java 代码示例

📅  最后修改于: 2022-03-11 14:52:09.893000             🧑  作者: 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);