Java File List Load getFileList(String folderPath)

Here you can find the source of getFileList(String folderPath)

Description

listFilesForFolder

License

Open Source License

Parameter

Parameter Description
folderPath a parameter

Declaration

public static List<File> getFileList(String folderPath) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*from  www. j  a va  2s.  c  o  m*/
     * listFilesForFolder
     * 
     * @param folderPath
     * @return 
     */
    public static List<File> getFileList(String folderPath) {
        // create output array
        List<File> files = new ArrayList<>();

        // create file object
        File folder = new File(folderPath);

        // iterate folder files
        for (final File fileEntry : folder.listFiles()) {

            // check if it's a file
            if (fileEntry.isFile()) {
                // save file paths in array
                files.add(fileEntry);
            }
        }

        // return list
        return files;
    }
}

Related

  1. getFileList(String dir, final String extension)
  2. getFileList(String dir, final String suffix)
  3. getFileList(String directory, String filterRegexp)
  4. getFileList(String directoryPath)
  5. getFileList(String filePath, FileFilter fileFilter, boolean recursive)
  6. getFileList(String inputFilename)
  7. getFileList(String path)
  8. getFileList(String path)
  9. getFileList(String path)