zhyiwww
          用平實(shí)的筆,記錄編程路上的點(diǎn)點(diǎn)滴滴………
          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);
                  }
              }
          				
          		


          |----------------------------------------------------------------------------------------|
                                     版權(quán)聲明  版權(quán)所有 @zhyiwww
                      引用請(qǐng)注明來(lái)源 http://www.aygfsteel.com/zhyiwww   
          |----------------------------------------------------------------------------------------|
          posted on 2006-06-13 11:49 zhyiwww 閱讀(309) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): code demo -java
          主站蜘蛛池模板: 凤冈县| 东兴市| 梁平县| 虎林市| 安阳县| 高尔夫| 凤庆县| 郎溪县| 九龙县| 印江| 肥东县| 兴海县| 凌海市| 延寿县| 京山县| 雷波县| 三穗县| 武定县| 玛纳斯县| 长子县| 乐平市| 南京市| 浦东新区| 体育| 陆良县| 襄城县| 宽城| 中牟县| 包头市| 黔西县| 夏邑县| 邢台县| 江门市| 东光县| 梧州市| 江安县| 成安县| 阿拉善盟| 武陟县| 阿图什市| 正蓝旗|