How To Check If Directory Is Empty In Java
With JDK >= 7 you can use Files.newDirectoryStream to open the directory and then use the iterator's hasNext() method to test there are any files to iterator over. This should work better for huge directories or where the directory is on a remote file system when compared to the java.io.File list methods.
Comments
Post a Comment