ตัวอย่าง
package demo.directory; import java.io.File; public class CheckEmptyDirectoryExample { /** * @param args */ public static void main(String[] args) { File file = new File("C:\\users\\nopphanan7\\Directory1"); 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"); } } }ผลลัพธ์ที่ได้คือ
Directory is not empty!
0 comments:
Post a Comment