posts - 33,  comments - 17,  trackbacks - 0
           1/**
           2     * 列出某文件夾及其子文件夾下面的文件,并可根據(jù)擴(kuò)展名過(guò)濾
           3     * 
           4     * @param path
           5     */

           6    public static void list(File path)
           7    {
           8        if (!path.exists())
           9        {
          10            System.out.println("文件名稱不存在!");
          11        }

          12        else
          13        {
          14            if (path.isFile())
          15            {
          16                if (path.getName().toLowerCase().endsWith(".pdf")
          17                        || path.getName().toLowerCase().endsWith(".doc")
          18                        || path.getName().toLowerCase().endsWith(".html")
          19                        || path.getName().toLowerCase().endsWith(".htm"))
          20                {
          21                    System.out.println(path);
          22                    System.out.println(path.getName());
          23                }

          24            }

          25            else
          26            {
          27                File[] files = path.listFiles();
          28                for (int i = 0; i < files.length; i++)
          29                {
          30                    list(files[i]);
          31                }

          32            }

          33        }

          34    }
          posted on 2008-07-23 17:26 scea2009 閱讀(137) 評(píng)論(0)  編輯  收藏

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


          網(wǎng)站導(dǎo)航:
           

          <2008年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          PL/SQL存儲(chǔ)過(guò)程與函數(shù)

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 浦城县| 怀安县| 博乐市| 垣曲县| 体育| 紫云| 黔西县| 赣榆县| 博爱县| 宁南县| 绵阳市| 林芝县| 道真| 浪卡子县| 繁峙县| 彰化县| 岐山县| 长寿区| 平湖市| 永和县| 博乐市| 曲靖市| 颍上县| 和龙市| 隆尧县| 乐昌市| 旌德县| 玉门市| 阿拉尔市| 中牟县| 斗六市| 射阳县| 浪卡子县| 安吉县| 茂名市| 华坪县| 荃湾区| 怀仁县| 伊金霍洛旗| 兴业县| 兴山县|