Java Folder Read getFiles(String realpath, List files, String[] fileType)

Here you can find the source of getFiles(String realpath, List files, String[] fileType)

Description

get Files

License

Open Source License

Declaration

public static List<java.io.File> getFiles(String realpath, List<File> files, String[] fileType) 

Method Source Code


//package com.java2s;

import java.io.File;

import java.util.List;

public class Main {

    public static List<java.io.File> getFiles(String realpath, List<File> files, String[] fileType) {
        File realFile = new File(realpath);
        if (realFile.isDirectory()) {
            File[] subfiles = realFile.listFiles();
            for (File file : subfiles) {
                if (file.isDirectory()) {
                    getFiles(file.getAbsolutePath(), files, fileType);
                } else {
                    if (isFileType(file.getName(), fileType)) {
                        files.add(file);
                    }// w w w .  j  a  v  a 2s  .com
                }
            }
        }
        return files;
    }

    public static boolean isFileType(String fileName, String[] typeArray) {
        for (String type : typeArray) {
            if (fileName.toLowerCase().endsWith(type)) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. getFiles(String path)
  2. getFiles(String path)
  3. getFiles(String path, final String suffix)
  4. getFiles(String path, String endian)
  5. getFiles(String paths)
  6. getFiles(String rootDirectory)
  7. getFiles(String thePaths[])
  8. getFilesAndFilesSubDirectories(String directoryName, String regexPattern)
  9. getFilesArray(File baseStorePath, final String fileNameSearchPattern)