Java File List Load getFilesByExt(String dirName, String ext)

Here you can find the source of getFilesByExt(String dirName, String ext)

Description

get Files By Ext

License

Open Source License

Declaration

public static File[] getFilesByExt(String dirName, String ext) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    private static String extension;

    public static File[] getFilesByExt(String dirName, String ext) {
        File dir = new File(dirName);
        extension = ext;//from  www  . j  av a  2  s .  c om

        return dir.listFiles(new FilenameFilter() {
            @Override
            public boolean accept(File dir, String fileName) {
                return fileName.endsWith(extension);
            }
        });
    }
}

Related

  1. getFileListing(File directory)
  2. getFileListing(File file)
  3. getFileListing(File file, String... extension)
  4. getFileListingLogs(File aStartingDir)
  5. getFileListingNoSort(File aStartingDir, boolean recursive)
  6. getFilesFromDir(File dir)
  7. getFilesFromDirectory(final File folder)
  8. getFilesFromDirectory(final String directory)
  9. getFilesFromDirectoryByExtension(File directory, String extension)