Here you can find the source of getAllFilesWithExtension(String folderPath, String extension)
public static Iterable<File> getAllFilesWithExtension(String folderPath, String extension)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; import java.util.Arrays; import java.util.stream.Collectors; public class Main { public static Iterable<File> getAllFilesWithExtension(String folderPath, String extension) { File folder = new File(folderPath); File[] files = folder.listFiles(); if (files == null) { return new ArrayList<>(); }//from w w w . java 2 s . co m return Arrays.asList(files).stream() .filter(file -> file.isFile() && file.getName().toLowerCase().endsWith(extension.toLowerCase())) .collect(Collectors.toList()); } }