Here you can find the source of getFileList(File sourceDirectory, final String extension)
public static List<File> getFileList(File sourceDirectory, final String extension)
//package com.java2s; /******************************************************************************* * Copyright (c) 2004, 2007 Boeing.// w w w . j a v a2s. c o m * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Boeing - initial API and implementation *******************************************************************************/ import java.io.File; import java.io.FilenameFilter; import java.util.Arrays; import java.util.List; public class Main { public static List<File> getFileList(File sourceDirectory, final String extension) { File[] listOfFiles = sourceDirectory.listFiles(new FilenameFilter() { @Override public boolean accept(File directoryName, String filename) { return filename.endsWith(extension) && new File(directoryName + File.separator + filename).canRead(); } }); return Arrays.asList(listOfFiles); } }