zhyiwww
          用平實的筆,記錄編程路上的點點滴滴………
          posts - 536,comments - 394,trackbacks - 0

          This example implements methods that recursively visits all files and directories under a directory.

          				
          						// Process all files and directories under dir
              public static void visitAllDirsAndFiles(File dir) {
                  process(dir);
              
                  if (dir.isDirectory()) {
                      String[] children = dir.list();
                      for (int i=0; i<children.length; i++) {
                          visitAllDirsAndFiles(new File(dir, children[i]));
                      }
                  }
              }
              
              // Process only directories under dir
              public static void visitAllDirs(File dir) {
                  if (dir.isDirectory()) {
                      process(dir);
              
                      String[] children = dir.list();
                      for (int i=0; i<children.length; i++) {
                          visitAllDirs(new File(dir, children[i]));
                      }
                  }
              }
              
              // Process only files under dir
              public static void visitAllFiles(File dir) {
                  if (dir.isDirectory()) {
                      String[] children = dir.list();
                      for (int i=0; i<children.length; i++) {
                          visitAllFiles(new File(dir, children[i]));
                      }
                  } else {
                      process(dir);
                  }
              }
          				
          		


          |----------------------------------------------------------------------------------------|
                                     版權聲明  版權所有 @zhyiwww
                      引用請注明來源 http://www.aygfsteel.com/zhyiwww   
          |----------------------------------------------------------------------------------------|
          posted on 2006-06-13 11:49 zhyiwww 閱讀(308) 評論(0)  編輯  收藏 所屬分類: code demo -java
          主站蜘蛛池模板: 湛江市| 平乐县| 麻阳| 天峨县| 洛隆县| 广元市| 庆元县| 邛崃市| 文化| 南昌县| 西林县| 弥勒县| 思南县| 拜城县| 通化县| 霍州市| 兰西县| 怀宁县| 冀州市| 阳城县| 白银市| 班玛县| 夹江县| 牡丹江市| 临洮县| 武鸣县| 大同市| 翁源县| 富阳市| 惠来县| 太湖县| 达州市| 海兴县| 成都市| 武威市| 昂仁县| 廊坊市| 正定县| 辽阳县| 汪清县| 栖霞市|