Java File List Load getFilesFromDir(File dir)

Here you can find the source of getFilesFromDir(File dir)

Description

get Files From Dir

License

Apache License

Declaration

public static List<File> getFilesFromDir(File dir) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<File> getFilesFromDir(File dir) {
        List<File> files = new ArrayList<File>();
        for (File f : dir.listFiles()) {
            if (!dir.exists())
                continue;
            if (f.isDirectory()) {
                List<File> _files = getFilesFromDir(f);
                files.addAll(_files);//  w ww. j  av  a2  s.c o  m
                continue;
            }

            files.add(f);
        }

        return files;
    }
}

Related

  1. getFileListing(File file)
  2. getFileListing(File file, String... extension)
  3. getFileListingLogs(File aStartingDir)
  4. getFileListingNoSort(File aStartingDir, boolean recursive)
  5. getFilesByExt(String dirName, String ext)
  6. getFilesFromDirectory(final File folder)
  7. getFilesFromDirectory(final String directory)
  8. getFilesFromDirectoryByExtension(File directory, String extension)