Java Utililty Methods File List Load

List of utility methods to do File List Load

Description

The list of methods to do File List Load are organized into topic(s).

Method

File[]getFileListInFolderForImages(String imageFolder)
get File List In Folder For Images
File dir = new File(imageFolder);
final String[] EXTENSIONS = new String[] { "gif", "png", "bmp", "jpg", "PNG", "JPG", "BMP", "GIF" 
};
FilenameFilter IMAGE_FILTER = new FilenameFilter() {
    @Override
    public boolean accept(final File dir, final String name) {
        for (final String ext : EXTENSIONS) {
            if (name.endsWith("." + ext)) {
...
ListgetFileListing(File aStartingDir)
get File Listing
validateDirectory(aStartingDir);
List<File> result = new ArrayList<File>();
File[] filesAndDirs = aStartingDir.listFiles();
List<File> filesDirs = Arrays.asList(filesAndDirs);
for (File file : filesDirs) {
    if (!file.isFile()) {
        List<File> deeperList = getFileListing(file);
        result.addAll(deeperList);
...
ListgetFileListing(File dir)
get File Listing
List<File> result = new ArrayList<File>();
for (String filename : dir.list())
    result.add(new File(dir, filename));
return result;
ListgetFileListing(File directory)
get File Listing
class JARFilter implements FilenameFilter {
    public boolean accept(File dir, String name) {
        return (name.endsWith(".jar"));
List result = new ArrayList();
File[] filesAndDirs = directory.listFiles();
List filesDirs = Arrays.asList(filesAndDirs);
...
ListgetFileListing(File file)
get File Listing
List<File> list = new ArrayList<File>();
if (file.isDirectory()) {
    for (File f : file.listFiles()) {
        list.addAll(getFileListing(f));
} else {
    return Arrays.asList(new File[] { file });
return list;
ListgetFileListing(File file, String... extension)
Gets the file listing.
List<File> list = new ArrayList<File>();
if (file.isDirectory()) {
    for (File f : file.listFiles()) {
        list.addAll(getFileListing(f, extension));
} else {
    List<File> l = new ArrayList<File>();
    for (String ext : extension) {
...
ListgetFileListingLogs(File aStartingDir)
Get all log files and directories and make recursive call.
List<File> result = new ArrayList<File>();
File[] logfiles = aStartingDir.listFiles(new FileFilter() {
    @Override
    public boolean accept(File pathname) {
        return pathname.isFile();
});
List<File> logFilesList = Arrays.asList(logfiles);
...
ListgetFileListingNoSort(File aStartingDir, boolean recursive)
Get a list of all files/directories in a directory structure.
List<File> result = new ArrayList<File>();
File[] filesAndDirs = aStartingDir.listFiles();
List<File> filesDirs = Arrays.asList(filesAndDirs);
for (File file : filesDirs) {
    result.add(file); 
    if (file.isDirectory() && recursive) {
        List<File> nestedList = getFileListingNoSort(file, recursive);
        result.addAll(nestedList);
...
File[]getFilesByExt(String dirName, String ext)
get Files By Ext
File dir = new File(dirName);
extension = ext;
return dir.listFiles(new FilenameFilter() {
    @Override
    public boolean accept(File dir, String fileName) {
        return fileName.endsWith(extension);
});
...
ListgetFilesFromDir(File dir)
get Files From 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);
        continue;
...