Java Path File Check nio isDirEmpty(final Path directory)

Here you can find the source of isDirEmpty(final Path directory)

Description

is Dir Empty

License

Apache License

Declaration

public static boolean isDirEmpty(final Path directory) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
    public static boolean isDirEmpty(final Path directory) throws IOException {
        try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(directory)) {
            return !dirStream.iterator().hasNext();
        }//from  w  w w  .java  2 s  . co  m
    }
}

Related

  1. isDirectoryEmpty(Path dir)
  2. isDirectoryEmpty(Path directory)
  3. isDirectoryEmpty(Path path)
  4. isDirectoryEmpty(String dirPath)
  5. isDirectoryInPath(File p, File d)
  6. isEmpty(Path dir)
  7. isEmptyDir(Path dir)
  8. isEmptyDir(Path path)
  9. isEmptyDir(Path path)