Here you can find the source of isEmptyDir(Path dir)
private static boolean isEmptyDir(Path dir) throws IOException
//package com.java2s; //License from project: LGPL import java.io.*; import java.nio.file.*; public class Main { private static boolean isEmptyDir(Path dir) throws IOException { try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) { return !stream.iterator().hasNext(); }// w w w. ja va 2 s . c o m } }