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

          This example lists the files and subdirectories in a directory. To list all descendant files and subdirectories under a directory, see e33 Traversing the Files and Directories Under a Directory .

          				
          						File dir = new File("directoryName");
              
              String[] children = dir.list();
              if (children == null) {
                  // Either dir does not exist or is not a directory
              } else {
                  for (int i=0; i<children.length; i++) {
                      // Get filename of file or directory
                      String filename = children[i];
                  }
              }
              
              // It is also possible to filter the list of returned files.
              // This example does not return any files that start with `.'.
              FilenameFilter filter = new FilenameFilter() {
                  public boolean accept(File dir, String name) {
                      return !name.startsWith(".");
                  }
              };
              children = dir.list(filter);
              
              
              // The list of files can also be retrieved as File objects
              File[] files = dir.listFiles();
              
              // This filter only returns directories
              FileFilter fileFilter = new FileFilter() {
                  public boolean accept(File file) {
                      return file.isDirectory();
                  }
              };
              files = dir.listFiles(fileFilter);
          				
          		


          |----------------------------------------------------------------------------------------|
                                     版權聲明  版權所有 @zhyiwww
                      引用請注明來源 http://www.aygfsteel.com/zhyiwww   
          |----------------------------------------------------------------------------------------|
          posted on 2006-06-13 11:45 zhyiwww 閱讀(300) 評論(0)  編輯  收藏 所屬分類: code demo -java
          主站蜘蛛池模板: 灵璧县| 祁门县| 广宗县| 阿拉善右旗| 阿克苏市| 类乌齐县| 红安县| 九龙城区| 伊川县| 祥云县| 通辽市| 长汀县| 彰化县| 抚宁县| 介休市| 大名县| 兰州市| 扶风县| 澄江县| 阳江市| 乐清市| 江城| 贵阳市| 郴州市| 巴彦淖尔市| 泽州县| 华亭县| 大姚县| 南召县| 深州市| 营山县| 阜康市| 闻喜县| 章丘市| 喀什市| 松桃| 大连市| 大安市| 龙南县| 庐江县| 含山县|