Java Directory to File List getAllFiles(File directory)

Here you can find the source of getAllFiles(File directory)

Description

get All Files

License

Apache License

Declaration

private static List<File> getAllFiles(File directory) 

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 {
    private static List<File> getAllFiles(File directory) {
        List<File> fileList = new ArrayList<File>();
        File[] files = directory.listFiles();
        if (files != null) {
            for (File file : files) {
                fileList.add(file);/*from ww w .j a  va2s  .  c o m*/
                if (file.isDirectory()) {
                    fileList.addAll(getAllFiles(file));
                }
            }
        }
        return fileList;
    }
}

Related

  1. getAllFiles(File dir)
  2. getAllFiles(File dir)
  3. getAllFiles(File dir, List fileList)
  4. getAllFiles(File dir, List fileList)
  5. getAllFiles(File dir, Pattern filter)
  6. getAllFiles(File directory)
  7. getAllFiles(File directory, boolean hidden)
  8. getAllFiles(File directory, String rootPath)
  9. getAllFiles(File inFileOrDir, boolean recurseDir)