Java Directory to File List getAllFiles(String folderPath)

Here you can find the source of getAllFiles(String folderPath)

Description

get All Files

License

Open Source License

Declaration

public static List<File> getAllFiles(String folderPath) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static List<File> getAllFiles(String folderPath) {
        List<File> list = new ArrayList<File>();
        File file = getFile(folderPath);
        if (file.exists() && file.isDirectory()) {
            File filesTemp[] = file.listFiles();
            for (int i = 0; i < filesTemp.length; i++) {
                list.add(filesTemp[i]);//from  www .j  av  a  2  s. co m
            }
        }
        return list;
    }

    public static File getFile(String filePath) {
        File file = null;
        file = new File(filePath);
        return file;
    }

    public static boolean exists(String filePath) {
        boolean flag = false;
        File file = getFile(filePath);
        if (file != null && file.exists() && file.isFile()) {
            flag = true;
        }
        return flag;
    }
}

Related

  1. getAllFiles(String dir, String extension)
  2. getAllFiles(String dir, String filePattern)
  3. getAllFiles(String directory)
  4. getAllFiles(String directory)
  5. getAllFiles(String dirPath)
  6. getAllFiles(String path)
  7. getAllFiles(String path, boolean isDepth)
  8. getAllFiles(String sDirectoryPath)
  9. getAllFiles(String zipName, String fileNameRegEx)