Here you can find the source of find(File dir, String suffix, Set
public static List<File> find(File dir, String suffix, Set<String> ignore)
//package com.java2s; /**// w w w . j a va 2s . c o m * Copyright 2012-2015 Rafal Lewczuk <rafal.lewczuk@jitlogic.com> * <p/> * This is free software. You can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * <p/> * This software is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with this software. If not, see <http://www.gnu.org/licenses/>. */ import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Set; public class Main { public static List<File> find(File dir, String suffix, Set<String> ignore) { List<File> lst = new ArrayList<File>(); for (String fn : dir.list()) { if (ignore.contains(fn)) { continue; } File f = new File(dir, fn); if (f.isFile() && fn.endsWith(suffix)) { lst.add(f); } if (f.isDirectory() && !f.getPath().startsWith(".")) { lst.addAll(find(f, suffix, ignore)); } } return lst; } }