Java Empty Directory Example
Chapter:
File
Last Updated:
03-09-2016 12:44:04 UTC
Program:
/* ............... START ............... */
import java.io.File;
public class JavaEmptyDirectory {
public static void main(String[] args) {
File file = new File("/data");
if (file.isDirectory()) {
String[] files = file.list();
if (files.length > 0) {
System.out.println("The " + file.getPath() + " is not empty!");
}
}
}
}
/* ............... END ............... */
Output
The D://Java/file.txt is not empty!
Tags
Empty Directory, Java, File