At times we might want to search for some file in a directory traversing recursively into other directories with in that directory, I know getting the recursive program right at the first time is always a challenge. Or we might want to list all the contents of a directory. For all these operations the NIO2 [...]
Tag Archives: nio2
Listing and filtering directory content using Java NIO2
July 20, 2012
The Files class provides a method- newDirectoryStream to get the Directory contents for a give path instance. There are other overloaded versions of newDirectoryStream method which take in filters to apply on the directory content. Listing all files in the directory Using Files.newDirectoryStream method gives an instance of DirectoryStream class which is a Iterable i.e [...]






July 22, 2012
1 Comment