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

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 介休市| 漾濞| 方山县| 将乐县| 沾益县| 河津市| 浙江省| 会昌县| 安溪县| 赤峰市| 吕梁市| 汽车| 甘谷县| 个旧市| 蓬溪县| 浏阳市| 西吉县| 闽侯县| 澄城县| 禄劝| 西昌市| 库车县| 九龙县| 彰武县| 三穗县| 友谊县| 千阳县| 德化县| 乐至县| 河间市| 咸宁市| 右玉县| 万源市| 乌恰县| 法库县| 准格尔旗| 铜川市| 喀什市| 徐汇区| 利津县| 佛山市|