Java Utililty Methods Path File Check nio

List of utility methods to do Path File Check nio

Description

The list of methods to do Path File Check nio are organized into topic(s).

Method

booleanisDirectoryEmpty(Path path)
is Directory Empty
if (!Files.isDirectory(path)) {
    return false;
try (DirectoryStream<Path> ds = Files.newDirectoryStream(path)) {
    return !ds.iterator().hasNext();
} catch (IOException ex) {
    return false;
booleanisDirectoryEmpty(String dirPath)
is Directory Empty
Path path = Paths.get(dirPath);
try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) {
    return !stream.iterator().hasNext();
booleanisDirectoryInPath(File p, File d)
is Directory In Path
try {
    Path p_ = getAbsolutePath(p);
    Path d_ = getAbsolutePath(d);
    return d_.toString().startsWith(p_.toString());
} catch (NullPointerException | IOException e) {
    return false;
booleanisDirEmpty(final Path directory)
is Dir Empty
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(directory)) {
    return !dirStream.iterator().hasNext();
booleanisEmpty(Path dir)
is Empty
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
    return !stream.iterator().hasNext();
booleanisEmptyDir(Path dir)
is Empty Dir
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
    return !stream.iterator().hasNext();
booleanisEmptyDir(Path path)
is Empty Dir
try (DirectoryStream<Path> ds = Files.newDirectoryStream(path)) {
    Iterator<Path> files = ds.iterator();
    return !files.hasNext();
booleanisEmptyDir(Path path)
is Empty Dir
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(path)) {
    return !dirStream.iterator().hasNext();
} catch (Exception e) {
return false;
booleanisEqualPath(final Path file1, final String topLevelAbsolutePath)
is Equal Path
return topLevelAbsolutePath.equals(file1.toAbsolutePath().toString());
booleanisExcluded(Set excludes, Path path)
Checks if specified path is within excludes
for (PathMatcher matcher : excludes) {
    if (matcher.matches(path)) {
        return true;
return false;