Here you can find the source of isDirEmpty(final Path directory)
public static boolean isDirEmpty(final Path directory) throws IOException
//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 } }