Java Directory to File List getAllFilesInDirectory(File directory, List files)

Here you can find the source of getAllFilesInDirectory(File directory, List files)

Description

get All Files In Directory

License

Open Source License

Declaration

public static void getAllFilesInDirectory(File directory, List<File> files) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2016 Weasis Team and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from   ww w  .  ja v a  2  s . c  om
 *     Nicolas Roduit - initial API and implementation
 *******************************************************************************/

import java.io.File;

import java.util.List;

public class Main {
    public static void getAllFilesInDirectory(File directory, List<File> files) {
        File[] fList = directory.listFiles();
        for (File f : fList) {
            if (f.isFile()) {
                files.add(f);
            } else if (f.isDirectory()) {
                getAllFilesInDirectory(f, files);
            }
        }
    }
}

Related

  1. getAllFilesFromFolder(File sampleFolder, ArrayList fileList, FilenameFilter filenameFilter)
  2. getAllFilesIn(File dir, final String type)
  3. getAllFilesInAllSubDirectories(File parentDir, FileFilter filter)
  4. getAllFilesInDir(boolean traverseSubDirs, File dir, boolean includeHidden, String prefix)
  5. getAllFilesInDirectory(File dir)
  6. getAllFilesInDirectory(String directoryPath)
  7. getAllFilesInDirectory(String dirName)
  8. getAllFilesInDirectory(String path)
  9. getAllFilesInDirMatchingPattern(String directory, final String regex, final boolean first_match2)