How to retrieve a list of directories QUICKLY in Java?

后端 未结 14 976
轮回少年
轮回少年 2020-12-01 12:45

Suppose a very simple program that lists out all the subdirectories of a given directory. Sound simple enough? Except the only way to list all subdirectories in Java is to u

14条回答
  •  借酒劲吻你
    2020-12-01 13:07

    As of 2020, the DirectoryStream does seem to be faster than using File.listFiles() and checking each file with isDirectory().

    I learned the answer from here:

    https://www.baeldung.com/java-list-directory-files

    I'm using Java 1.8 on Windows 10.

提交回复
热议问题