Dealing with Directories
The java.nio.file.DirectoryStream interface and its implementing classes allow you to:
- Iterate over entries in a directory.
- Deal with large directory structures.
- Filter entries whilst processing using regular expressions and MIME based content detection.
- Walk the tree structure in order to perform recursive move, copy, delete operations.
Path dir = Paths.get("c:\\workspace");
stream = dir.newDirectoryStream("*.java");
catch (IOException e)
As you can see, with the new Java 7 APIs this particular task is much simpler than it used to be and this theme is prevalent in the rest of the NIO.2 APIs.
So are we there yet? In terms of File and Directory interaction in Java 7 there's certainly a massive improvement, so I'll say "Yes" once Java 7 is released.