Java Directory to File List getAllFilesRecursively(File dir, List filelist)

Here you can find the source of getAllFilesRecursively(File dir, List filelist)

Description

get All Files Recursively

License

Open Source License

Declaration

private static void getAllFilesRecursively(File dir, List<File> filelist) 

Method Source Code


//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

import java.io.File;

import java.util.List;

public class Main {
    private static void getAllFilesRecursively(File dir, List<File> filelist) {
        File[] files = dir.listFiles();
        if (files == null) {
            return;
        }//  w w  w  .jav a2s . c  o m
        int i;
        for (i = 0; i < files.length; ++i) {
            if (files[i].isFile()) {
                filelist.add(files[i]);
            } else if (files[i].isDirectory()) {
                getAllFilesRecursively(files[i], filelist);
            }
        }
    }
}

Related

  1. getAllFilesInternal(final File aPath, final FilenameFilter filter, final List fileList)
  2. getAllFilesLeastRecentFirst(File directory)
  3. getAllFilesMatching(File srcDir, final String regex)
  4. getAllFilesMatchingThisPatternIgnoreCase(String sDirectoryPath, String sPattern)
  5. getAllFilesPresentInFolder(File srcPath)
  6. getAllFilesRecursively(File directory, Collection files)
  7. getAllFilesWithExtension(String directory, final String extension)
  8. getAllFilesWithExtension(String folderPath, String extension)
  9. getAllFilesWithFilter(String DirectoryName, FilenameFilter Filter)