递归遍历目录

@param folder   目录
@param fileList 储存文件
161328
private static void enumerate(File folder, List<File> fileList)
    {
        File[] fileArray = folder.listFiles();
        if (fileArray != null)
        {
            for (File file : fileArray)
            {
                if (file.isFile() && !file.getName().startsWith(".")) // 过滤隐藏文件
                {
                    fileList.add(file);
                }
                else
                {
                    enumerate(file, fileList);
                }
            }
        }
    }
447120
private void populateFileList(ResourceFileList list, File root, boolean recurse) 
	throws IOException {
		if(root.isDirectory()) {
			File[] files = root.listFiles();
			if(files != null) {
				for(File file : files) {
					if(file.isFile() && filter.accept(root, file.getName())) {
						ResourceFileLocation location = new ResourceFileLocation(
								file.getName(),file.getAbsolutePath());
						list.add(location);
					} else if(recurse && file.isDirectory()){
						populateFileList(list, file, recurse);
					}
				}
			}
		} else {
			LOGGER.warning(root.getAbsolutePath() +	" is not a directory.");
			return;
		}
	}
1329030
public static List<File> listDirs(final File dir)
	{
		final List<File> foundedDirs = new ArrayList<>();
		final File[] fileArray = dir.listFiles();
		for (final File element : fileArray)
		{
			if (element.isDirectory())
			{
				foundedDirs.add(element);
			}
		}
		return foundedDirs;

	}
1314598
def get_folder_list(folder='.'):
    
    dir_list = get_content_list(folder)
    return [f for f in dir_list if not os.path.isfile(os.path.join(folder, f))]
1032793
public void setFileShareInfoList(java.util.Collection<FileShareInfo> fileShareInfoList) {
        if (fileShareInfoList == null) {
            this.fileShareInfoList = null;
            return;
        }

        this.fileShareInfoList = new com.amazonaws.internal.SdkInternalList<FileShareInfo>(fileShareInfoList);
    }
787285
public synchronized void configure(String folder) {
        Assert.notNull(folder, "'folder' must not be null");

        if (!staticResourcesSet) {

            if (staticResourceHandlers == null) {
                staticResourceHandlers = new ArrayList<>();
            }

            staticResourceHandlers.add(new ClassPathResourceHandler(folder, "index.html"));
            LOG.info("StaticResourceHandler configured with folder = " + folder);
            staticResourcesSet = true;
        }
    }
1333918
public static void addFilesRecursively(File dir, Collection<File> fileCollection) {
		log.debug("Adding files from {}", dir.getPath());
		File[] files = dir.listFiles();
		for (File file : files) {
			if (file.isDirectory())
				addFilesRecursively(file, fileCollection);
			else {
				fileCollection.add(file);
			}
		}
	}
1118339
private void cleanDir(File dir) {
        File[] files = dir.listFiles();
        if (files != null && files.length > 0) {
            for (int i = 0; i < files.length; i++) {
                File file = files[i];
                // if file is a directory, first delete all the files inside, then delete the directory itself.
                if (file.isDirectory()) {
                    cleanDir(file);
                }
                if (!file.delete()) {
                    throw new BuildException(MessageFormat.format(messages.getString("error.cannot.delete.file"), file.getAbsolutePath()));
                }
            }
        }
    }
617684
private void addWorkListItemsForExtDir(LinkedList<WorkListItem> workList, String extDir) {
        File dir = new File(extDir);
        File[] fileList = dir.listFiles((FileFilter) pathname -> {
            String path = pathname.getPath();
            boolean isArchive = Archive.isArchiveFileName(path);
            return isArchive;
        });
        if (fileList == null) {
            return;
        }

        for (File archive : fileList) {
            addToWorkList(workList, new WorkListItem(classFactory.createFilesystemCodeBaseLocator(archive.getPath()), false,
                    ICodeBase.Discovered.IN_SYSTEM_CLASSPATH));
        }
    }
897496
public static void copyFiles(String[] files, String storageFolder) throws IOException {
        copyFiles(getFiles(files), storageFolder);
    }
770960
public void onSelectFolder(String folder, boolean selected) {

        if (selected) {
            m_controller.addFolder(folder);
        } else {
            m_controller.removeFolder(folder);
        }
    }
931884
private void mkdir(IStructuredSelection selection) {
    List<DFSFolder> folders = filterSelection(DFSFolder.class, selection);
    if (folders.size() >= 1) {
      DFSFolder folder = folders.get(0);
      InputDialog dialog =
          new InputDialog(Display.getCurrent().getActiveShell(),
              "Create subfolder", "Enter the name of the subfolder", "",
              null);
      if (dialog.open() == InputDialog.OK)
        folder.mkdir(dialog.getValue());
    }
  }
1356380
private static void deleteContents(File dir) {
        if (dir != null && dir.exists()) {
            for (File f : dir.listFiles()) {
                if (f.isDirectory()) {
                    deleteContents(f);
                }
                f.delete();
            }
        }
    }
87034
public void clearDirectory(File directory) {
        if (directory.exists()) {
            for (File file : directory.listFiles()) {
                file.delete();
            }
        }
    }
798044
@GuardedBy("writeLock")
   private void updateFileList(FileListCacheValue fileList) {
      if (writeAsync) {
         cacheNoRetrieve.putAsync(fileListCacheKey, fileList);
      }
      else {
         if (trace) {
            log.tracef("Updating file listing view from %s", getAddress(cacheNoRetrieve));
         }
         cacheNoRetrieve.put(fileListCacheKey, fileList);
      }
   }
471083
private ArrayList<String> getFiles(String dir, String subDir) {
    ArrayList<String> files = new ArrayList<>();
    String fullDir = subDir == null ? dir : dir + File.separator + subDir;
    File[] listOfFiles = (new File(fullDir)).listFiles();
    if (listOfFiles != null) {
      for (File file : listOfFiles) {
        String fullName = subDir == null ? file.getName() : subDir + File.separator + file.getName();
        if (file.isFile()) {
          files.add(fullName);
        } else if (file.isDirectory()) {
          files.addAll(getFiles(dir, fullName));
        }
      }
    }
    return files;
  }
394257
public void setFilePath(String filePath)
    {
        //create a new file
        File fileInstance=null;
        if(filePath!=null)
        {
            fileInstance=new File(filePath);
        }
        
        //set file
        this.setFile(fileInstance);
    }