Here you can find the source of getFileList(String dir, final String suffix)
public static List<String> getFileList(String dir, final String suffix)
//package com.java2s; /*/*from w ww .j a va2 s.c om*/ * #%L * Util.java - method51 - University of Sussex - 2,013 * %% * Copyright (C) 2013 - 2014 University of Sussex * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ import java.io.*; import java.util.*; public class Main { public static List<String> getFileList(String dir, final String suffix) { File f = new File(dir); if (!f.exists()) return Collections.EMPTY_LIST; if (!f.isDirectory()) return Arrays.asList(f.getName()); List<String> names = new ArrayList<>(Arrays.asList(f.list(new FilenameFilter() { public boolean accept(File dir, String name) { return name.toLowerCase().endsWith(suffix) && !name.startsWith("."); } }))); Collections.sort(names); return names; } }