I have some file I/0 traversal code written in Java 6, trying to move it the New I/O in Java 7 but I cannot find any replacement for this kind of stuff.
File
Using Files#newDirectoryStream and DirectoryStream.Filter
Here is the code:
DirectoryStream<Path> stream = Files.newDirectoryStream(dir, new DirectoryStream.Filter<Path>() {
@Override
public boolean accept(Path entry) throws IOException
{
return Files.isDirectory(entry);
}
});
for (Path entry: stream) {
...
}
BTW, I omitted the exception handling in the above code for simplicity.