Im using Files.WalkFileTree()
to navigate folder and counting audio files, but there is a problem when it encounters a tar file, it seems to be treating it as a
Workaround for the problem at hand:
But implement a visitFileFailed and you should be ok.
public class MyFileVisitor extends SimpleFileVisitor<Path> {
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
if (file.toString().endsWith(".tar")) {
return FileVisitResult.CONTINUE;
}
return super.visitFileFailed(file, exc);
}
}
Update: If we look closer we can see that walkFileTree uses the Files.readAttributes which turns to the current provider in play: WindowsFileSystemProvider.readAttributes to determine if a path is a directory.
As someone mentioned in the comments I also dont think the fault is in the Java-implementation but the OS-native-call that returns the wrong attribute
If you wanted to do a workaround for this, one option would be to implement your own FileSystem that wraps the WindowsFileSystem implementation transparently, except readAttributes returns .tar-paths as file instead of dir.