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

String[]getFileList(String directory, String filterRegexp)
get File List
File rootDir = new File(directory);
String[] allFilenames = rootDir.list();
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(filterRegexp);
List<String> filteredFilenames = new ArrayList<String>();
for (int i = 0; i < allFilenames.length; i++) {
    Matcher matcher = pattern.matcher(allFilenames[i]);
    if (matcher.find()) {
        filteredFilenames.add(getPath(directory, allFilenames[i]));
...
String[]getFileList(String directoryPath)
get File List
File directory = new File(directoryPath);
if (directory.exists()) {
    return directory.list();
return new String[] {};
ArrayListgetFileList(String filePath, FileFilter fileFilter, boolean recursive)
Gets a ArrayList of File objects provided a dir or file path.
ArrayList<File> files = new ArrayList<File>();
File file = new File(filePath);
if (file.exists() && file.isDirectory()) {
    File[] fa = file.listFiles(fileFilter);
    for (int i = 0; i < fa.length; i++) {
        if (fa[i].isFile())
            files.add(fa[i]);
        else if (recursive && fa[i].isDirectory())
...
ListgetFileList(String folderPath)
listFilesForFolder
List<File> files = new ArrayList<>();
File folder = new File(folderPath);
for (final File fileEntry : folder.listFiles()) {
    if (fileEntry.isFile()) {
        files.add(fileEntry);
return files;
...
ArrayListgetFileList(String inputFilename)
getFileList If inputFilename is a normal file, and if each of its non-empty lines corresponds to a normal file, convert each to a File object and store in list.
File inputFile = getNormalFile(inputFilename);
ArrayList<File> fileList = new ArrayList<File>();
FileReader fr = new FileReader(inputFile);
BufferedReader br = new BufferedReader(fr);
String filename;
try {
    while ((filename = br.readLine()) != null) {
        filename = filename.trim();
...
File[]getFileList(String path)
get File List
File dirFile = new File(path);
File[] fileList = dirFile.listFiles();
return fileList;
String[]getFileList(String path)
get File List
File directory = new File(path);
if (directory.isDirectory()) {
    return directory.list();
} else {
    System.out.println("Lessons directory not found! at " + directory.getAbsolutePath());
    return null;
File[]getFileList(String path)
get File List
File[] fileList = new File(path).listFiles(new FileFilter() {
    @Override
    public boolean accept(File pathname) {
        String str = pathname.getName().toLowerCase();
        if (str.endsWith(".nes") || str.endsWith(".zip"))
            return true;
        else
            return false;
...
ListgetFileList(String path)
get File List
List<File> result = new ArrayList<File>();
File file = new File(path);
File[] tempList = file.listFiles();
for (int i = 0; i < tempList.length; i++) {
    if (tempList[i].isFile()) {
        result.add(tempList[i]);
    if (tempList[i].isDirectory()) {
...
ListgetFileList(String path)
get File List
File file = new File(path);
String[] array = null;
String temp = "";
if (!file.isDirectory()) {
    return null;
array = file.list();
if (array != null && array.length > 0) {
...