Here you can find the source of getAllFilesEndingWith(String path, final String extension)
public static ArrayList<File> getAllFilesEndingWith(String path, final String extension)
//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; } }