Here you can find the source of getFileListInFolderForImages(String imageFolder)
public static File[] getFileListInFolderForImages(String imageFolder)
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static File[] getFileListInFolderForImages(String imageFolder) { File dir = new File(imageFolder); final String[] EXTENSIONS = new String[] { "gif", "png", "bmp", "jpg", "PNG", "JPG", "BMP", "GIF" // and other formats you need };/*from w w w . j a v a 2 s .c om*/ // filter to identify images based on their extensions FilenameFilter IMAGE_FILTER = new FilenameFilter() { @Override public boolean accept(final File dir, final String name) { for (final String ext : EXTENSIONS) { if (name.endsWith("." + ext)) { return (true); } } return (false); } }; File[] list = dir.listFiles(IMAGE_FILTER); return list; } }