隨筆-71  評論-5  文章-0  trackbacks-0
           public static boolean delFilesByPath(String path,String str){
           //參數說明---------path:要刪除的文件的文件夾的路徑---------str:要匹配的字符串的頭
           boolean b=false;
           File file = new File(path); 
           File[] tempFile = file.listFiles(); 
           for(int i = 0; i < tempFile.length; i++){ 
            if(tempFile[i].getName().startsWith(str)||tempFile[i].getName().endsWith(str)){ 
             tempFile[i].delete();
             b=true;
            }
           }
           return b;
          }
           
          public static void main(String[] args) {
           String path="F:/Installed---success---go/apache/webapps/images";
           String str="181";
           if(delFilesByPath(path,str)){
            System.out.println(path+"中包含"+str+"的文件已經全部刪除成功!");
           }else{
            System.out.println(path+"中包含"+str+"的文件已經刪除失敗或該文件夾下不存在這類文件!");
           }
          }
          posted on 2015-03-06 10:09 藤本薔薇 閱讀(175) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 巴彦县| 石楼县| 会昌县| 玉门市| 荆州市| 广州市| 桃园市| 红河县| 前郭尔| 河东区| 正镶白旗| 贵溪市| 呼伦贝尔市| 琼中| 澳门| 淮安市| 凤庆县| 留坝县| 琼结县| 瑞丽市| 岳阳县| 平湖市| 涞源县| 三都| 宁阳县| 宿迁市| 额尔古纳市| 峨山| 怀宁县| 子长县| 林西县| 长沙县| 青铜峡市| 阜阳市| 文山县| 洛扎县| 屏东市| 维西| 高雄县| 综艺| 隆尧县|