Java File List Load getFileList(File sourceDirectory, final String extension)

Here you can find the source of getFileList(File sourceDirectory, final String extension)

Description

get File List

License

Open Source License

Declaration

public static List<File> getFileList(File sourceDirectory, final String extension) 

Method Source Code

//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);
    }
}

Related

  1. getFileList(File f, FileFilter filter, boolean recursive, boolean wantDirectory, boolean wantHidden, ArrayList list)
  2. getFileList(File file)
  3. getFileList(File file)
  4. getFileList(File file, String[] suffixs)
  5. getFileList(File folder, String type)
  6. getFileList(File[] fileArray)
  7. getFileList(final File dir, final String extension, final List list, final int maxDepth)
  8. getFileList(final List fileList, final File root, final File[] ignoreList)
  9. getFileList(final String location)