Java Directory to File List getAllFileNamesInDir(String folderName)

Here you can find the source of getAllFileNamesInDir(String folderName)

Description

Gets the all file names in dir.

License

LGPL

Parameter

Parameter Description
folderName the folder name

Return

the all file names in dir

Declaration

public static List<String> getAllFileNamesInDir(String folderName) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.io.File;

import java.util.ArrayList;
import java.util.List;

public class Main {
    /**//from   w  ww  .  j  av  a2  s .  c om
     * Gets the all file names in dir.
     *
     * @param folderName the folder name
     * @return the all file names in dir
     */
    public static List<String> getAllFileNamesInDir(String folderName) {
        List<String> fileList = new ArrayList<String>();
        File folder = new File(folderName);
        if (folder.exists() && folder.isDirectory()) {

            File[] libs = folder.listFiles();
            for (File lib : libs) {
                fileList.add(lib.getPath());
            }

        }

        return fileList;
    }
}

Related

  1. GetAllFileName(String path)
  2. getAllFileName(String path, ArrayList fileName)
  3. getAllFileNames(File basedir, String path)
  4. getAllFileNames(String path, String suffix, boolean isDepth)
  5. getAllFileNamesByPath(String path)
  6. getAllFileNamesWithExtension(String directory, final String extension)
  7. getAllFilePath(String filedir)
  8. getAllFiles(File dir)
  9. getAllFiles(File dir)