Path.getFileName() may return null if the path has zero elements.
Enclose the dereference in a null-check.
Change-Id: I7ea3d3f07edc13a80b593d28e8fd512a4e1ed56b
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
- String name = file.getFileName().toString();
- if (!attrs.isDirectory() && badName.test(name)) {
- bad.add(name);
+ Path fileName = file.getFileName();
+ if (fileName != null) {
+ String name = fileName.toString();
+ if (!attrs.isDirectory() && badName.test(name)) {
+ bad.add(name);
+ }
}
return FileVisitResult.CONTINUE;
}