package org.kodejava.io;
import java.io.File;
public class EmptyDirCheck {
public static void main(String[] args) {
File file = new File("D:/Downloads");
// Check to see if the object represent a directory.
if (file.isDirectory()) {
// Get list of file in the directory. When its length is not zero
// the folder is not empty.
String[] files = file.list();
if (files != null && files.length > 0) {
System.out.println(file.getPath() + " is not empty!");
}
}
}
}
Latest posts by Wayan (see all)
- How do I get number of each day for a certain month in Java? - September 8, 2024
- How do I get operating system process information using ProcessHandle? - July 22, 2024
- How do I sum a BigDecimal property of a list of objects using Java Stream API? - July 22, 2024