判斷文件夾下有沒有文件

/**
     * 判斷文件夾下有沒有文件
     * @param targetPath
     * @return 有返回fasle,沒有返回true,路徑不存在返回false
     */
    public static boolean judgeListFiles(String targetPath){ 
File targetFile = new File(targetPath); 
if(targetFile.exists()){
if (targetFile.listFiles().length>0) { 
    return false;
}
return true;

return false;
    }
發佈了20 篇原創文章 · 獲贊 5 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章