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

File[]getFiles(String PATH)
get Files
LinkedList<File> file_list = new LinkedList<File>();
LinkedList<File> directory_queue = new LinkedList<File>();
File ROOT_FILE = new File(PATH);
File files[];
if (!ROOT_FILE.isDirectory())
    return null;
else
    directory_queue.add(ROOT_FILE);
...
ListgetFiles(String path)
getFiles
File dir = new File(path);
if (dir.exists()) {
    File[] files = dir.listFiles();
    if (files != null && files.length > 0) {
        return initDirs(files);
return Collections.emptyList();
...
File[]getFiles(String path)
Returns the files laid in the specified folder path
if (isDirectory(path)) {
    File file = new File(path);
    return file.listFiles(new FileFilter() {
        @Override
        public boolean accept(File file) {
            if (file.getName().startsWith(".")) {
                return false;
            return true;
    });
return null;
ListgetFiles(String path)
get Files
List<String> classes = new ArrayList<String>();
for (File file : new File(path).listFiles()) {
    if (file.getName().endsWith(".java")) {
        classes.add(file.getPath());
    } else if (file.isDirectory() && !file.getName().startsWith(".")) {
        classes.addAll(getFiles(file.getAbsolutePath()));
return classes;
ArrayListgetFiles(String path, final String suffix)
get Files
ArrayList<File> flist = new ArrayList<File>();
File[] files = (new File(path)).listFiles();
for (File file : files) {
    if (file.isDirectory())
        flist.addAll(getFiles(file.getAbsolutePath(), suffix));
    else if (file.getName().endsWith(suffix))
        flist.add(file);
return flist;
ArrayListgetFiles(String path, String endian)
get Files
ArrayList<File> matches = new ArrayList<File>();
File folder = new File(path);
File files[] = folder.listFiles();
for (File f : files)
    if (f.getName().endsWith(endian))
        matches.add(f);
return matches;
ListgetFiles(String paths)
get Files
List<File> filesList = new ArrayList<>();
for (final String path : paths.split(File.pathSeparator)) {
    final File file = new File(path);
    if (file.isDirectory()) {
        recurse(filesList, file);
    } else {
        filesList.add(file);
return filesList;
ListgetFiles(String realpath, List files, String[] fileType)
get Files
File realFile = new File(realpath);
if (realFile.isDirectory()) {
    File[] subfiles = realFile.listFiles();
    for (File file : subfiles) {
        if (file.isDirectory()) {
            getFiles(file.getAbsolutePath(), files, fileType);
        } else {
            if (isFileType(file.getName(), fileType)) {
...
ListgetFiles(String rootDirectory)
get Files
File[] files = new File(rootDirectory).listFiles();
List<String> result = new ArrayList();
for (File file : files) {
    if (!file.isDirectory()) {
        result.add(file.getAbsolutePath());
    } else if (file.isDirectory()) {
        result.addAll(getFiles(file.getAbsolutePath()));
return result;
File[]getFiles(String thePaths[])
Returns the Files for given paths.
File files[] = new File[thePaths.length];
for (int i = 0; i < thePaths.length; i++)
    files[i] = getFile(thePaths[i]);
return files;