Java Folder Read by Extension getFiles(File dir, String fileExtension)

Here you can find the source of getFiles(File dir, String fileExtension)

Description

Returns all files in the given directory that end on fileExtension.

License

Apache License

Parameter

Parameter Description
dir a parameter
fileExtension a parameter

Declaration

public static List<File> getFiles(File dir, String fileExtension) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.util.Arrays;
import java.util.List;

public class Main {
    /**//from  www.  j a va 2 s  .co  m
     * Returns all files in the given directory that end on <b>fileExtension</b>.
     * 
     * @param dir
     * @param fileExtension
     * @return
     */
    public static List<File> getFiles(File dir, String fileExtension) {
        File[] files = dir.listFiles((f, s) -> s.endsWith(fileExtension));
        return Arrays.asList(files);
    }
}

Related

  1. getFiles(File baseDir, String validExtension, List files)
  2. getFiles(File dir, final String extension)
  3. getFiles(File dir, final String extension)
  4. getFiles(File dir, final String extensionFilter)
  5. getFiles(File folder, String... extensions)
  6. getFiles(final String path, final String ext)
  7. getFiles(String dir, String ext)
  8. getFiles(String dir, String... extension)