|
import java.io.File;
public class CheckFolderEmptyExample {
public static void main(String[] args) {
File file = new File("D:\testout");
if (file.isDirectory()) {
// check thu muc rong bang phuong thuc file.list()
if (file.list().length == 0) {
System.out.println("Thu muc "
+ file.getAbsolutePath() + " la rong!");
} else {
System.out.println("Thu muc "
+ file.getAbsolutePath() + " khong rong!");
}
} else {
System.out.println(file.getAbsolutePath() + " khong phai la thu muc!");
}
}
}
|