Java Utililty Methods Folder Read

List of utility methods to do Folder Read

Description

The list of methods to do Folder Read are organized into topic(s).

Method

ListgetFiles(File directory)
Scans a local directory for existing files.
ArrayList<String> files = new ArrayList<String>();
File[] filesInDir = directory.listFiles();
for (int i = 0; i < filesInDir.length; i++) {
    File file = filesInDir[i];
    if (file.isFile()) {
        files.add(file.getName());
return files;
ListgetFiles(File directory)
Get a listing of all the files in this directory which matches the given pattern.
return getFiles(directory, null, false);
ArrayListgetFiles(File directory)
Get a list of all files in a directory, ignoring subdirectories.
return getFiles(directory, false);
voidgetFiles(File f, List response)
get Files
File files[];
if (f.isFile()) {
    response.add(f.getAbsolutePath());
} else {
    files = f.listFiles();
    for (int i = 0; i < files.length; i++) {
        getFiles(files[i], response);
ListgetFiles(File file)
Get all of the files from the direct folder
List<File> fileList = new ArrayList<File>();
if (file.isDirectory()) {
    for (File child : file.listFiles()) {
        fileList.addAll(getFiles(child));
} else {
    fileList.add(file);
return fileList;
voidgetFiles(File file, Collection ret)
get Files
if (file.isDirectory()) {
    for (File f : file.listFiles())
        getFiles(f, ret);
} else
    ret.add(file);
ListgetFiles(File folder)
get Files
if (!folder.exists())
    folder.mkdirs();
List<File> list = new ArrayList<File>();
for (File fileEntry : folder.listFiles()) {
    if (fileEntry.isDirectory()) {
        getFiles(fileEntry);
    } else {
        list.add(fileEntry);
...
ListgetFiles(File folder)
get Files
List<File> files = new ArrayList<File>();
iterateFolder(folder, files);
return files;
File[]getFiles(File folder)
get Files
if (folder != null && folder.exists()) {
    File[] files = folder.listFiles();
    if (files != null)
        return files;
return new File[0];
CollectiongetFiles(File indir)
Get all files (excluding directories) under dir.
if (!indir.isDirectory()) {
    throw new IllegalArgumentException("Expected directory as input");
Collection<File> rtn = new HashSet<File>();
List<File> dirs = new ArrayList<File>();
dirs.add(indir);
while (!dirs.isEmpty()) {
    File dir = dirs.remove(0);
...