Get large directory content faster (java.io.File alternatives)
I've used the old, obsolete java.io.File.listFiles() for too long. The performance is not so good. It is: Expensive, since it creates a new File object for each entry. Slow, because you have to wait for the array to be completed before starting the processing. Very bad, especially if you need to work only on subset of the content. What are the alternatives? The Java 7's java.nio.file package can be used to enhance performance. Iterators The DirectoryStream<T> interface can be used to iterate over a directory without preloading its content into memory. While the old API creates an array of all