Get the listing of directory and check its length to know if directory is empty
Example
File file = new File("C:\\folder");
if (file.isDirectory()) {
if(file.list().length > 0) {
System.out.println("Directory is not empty !");
} else {
System.out.println("Directory is empty !");
}
} else {
System.out.println("This is not a directory");
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.