Java Path File Check nio isEmpty(Path dir)

Here you can find the source of isEmpty(Path dir)

Description

is Empty

License

Open Source License

Declaration

public static boolean isEmpty(Path dir) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.nio.file.*;

public class Main {
    public static boolean isEmpty(String dir) throws IOException {
        return isEmpty(Paths.get(dir));
    }//from w  ww  .  j  a v a  2  s .co  m

    public static boolean isEmpty(Path dir) throws IOException {
        try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
            return !stream.iterator().hasNext();
        }
    }
}

Related

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