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

get All Files Ending With

License

Mozilla Public License

Declaration

public static ArrayList<File> getAllFilesEndingWith(String path,
            final String extension) 

Method Source Code

//package com.java2s;
/**  //from  w  w w  .j av  a 2s .  c  o m
 * SMART FP7 - Search engine for MultimediA enviRonment generated contenT
 * Webpage: http://smartfp7.eu
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 
 * 
 * The Original Code is Copyright (c) 2012-2014 the University of Glasgow
 * All Rights Reserved
 * 
 * Contributor(s):
 *  @author Romain Deveaud <romain.deveaud at glasgow.ac.uk>
 */

import java.io.File;

import java.io.FilenameFilter;

import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    public static ArrayList<File> getAllFilesEndingWith(String path,
            final String extension) {
        File directory = new File(path);
        ArrayList<File> files = new ArrayList<File>(Arrays.asList(directory
                .listFiles(new FilenameFilter() {
                    @Override
                    public boolean accept(File dir, String name) {
                        return name.endsWith(extension);
                    }
                })));

        return files;
    }
}

Related

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