Java File List Load getFileListInFolderForImages(String imageFolder)

Here you can find the source of getFileListInFolderForImages(String imageFolder)

Description

get File List In Folder For Images

License

Open Source License

Declaration

public static File[] getFileListInFolderForImages(String imageFolder) 

Method Source Code

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

Related

  1. getFileListByDFS(File file)
  2. getFileListByExtension(final String location, final String extension)
  3. getFileListByRegex(String dir, final String regex)
  4. getFileListDeep(File path)
  5. getFileListInFolder(String path)
  6. getFileListing(File aStartingDir)
  7. getFileListing(File dir)
  8. getFileListing(File directory)
  9. getFileListing(File file)