隨筆-71  評(píng)論-5  文章-0  trackbacks-0
           public static boolean delFilesByPath(String path,String str){
           //參數(shù)說(shuō)明---------path:要?jiǎng)h除的文件的文件夾的路徑---------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+"的文件已經(jīng)全部刪除成功!");
           }else{
            System.out.println(path+"中包含"+str+"的文件已經(jīng)刪除失敗或該文件夾下不存在這類(lèi)文件!");
           }
          }
          posted on 2015-03-06 10:09 藤本薔薇 閱讀(175) 評(píng)論(0)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 临沭县| 武鸣县| 墨竹工卡县| 天峻县| 石柱| 北宁市| 延边| 垣曲县| 通山县| 连平县| 基隆市| 西城区| 香港 | 桐梓县| 雅江县| 南宫市| 抚顺县| 城市| 周至县| 黑水县| 平原县| 宁城县| 富宁县| 璧山县| 张家界市| 抚松县| 府谷县| 漳平市| 中西区| 星子县| 图木舒克市| 昭觉县| 曲周县| 蚌埠市| 凤翔县| 兰坪| 苗栗县| 密云县| 乌拉特前旗| 雅江县| 青神县|