Java Directory to File List getAllFilesEndingWith(String path, final String extension)

Here you can find the source of getAllFilesEndingWith(String path, final String extension)

Description

Return an array of File objects ending with given extension

License

Apache License

Parameter

Parameter Description
extension a parameter

Declaration

public static File[] getAllFilesEndingWith(String path, final String extension) 

Method Source Code


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

import java.io.File;
import java.io.FilenameFilter;

public class Main {
    /**/*from  w  ww  .  j ava  2  s . c om*/
     * Return an array of {@link File} objects ending with given extension
     * @param extension
     * @return
     */
    public static File[] getAllFilesEndingWith(String path, final String extension) {
        File rootDirectory = new File(path);
        return rootDirectory.listFiles(new FilenameFilter() {

            public boolean accept(File dir, String name) {
                return name.toLowerCase().endsWith(extension);
            }
        });
    }
}

Related

  1. getAllFiles(String sDirectoryPath)
  2. getAllFiles(String zipName, String fileNameRegEx)
  3. getAllFiles(String[] args, boolean recurse)
  4. getAllFilesByExtension(String path, String extension)
  5. getAllFilesByProfix(String path, String suffix, List files)
  6. getAllFilesEndingWith(String path, final String extension)
  7. getAllFilesForType(File dir, FilenameFilter filter)
  8. getAllFilesFromDir(File dir)
  9. getAllFilesFromFolder(File aFolder, FilenameFilter filenameFilter)