Here you can find the source of find(File path, Boolean recursive)
Parameter | Description |
---|---|
path | the path to search |
recursive | iff true, search subdirectories too. |
public static ArrayList<File> find(File path, Boolean recursive)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.util.*; public class Main { /***// w w w . j a v a 2s. co m * Return all files beneath path. * @param path the path to search * @param recursive iff true, search subdirectories too. * @return */ public static ArrayList<File> find(File path, Boolean recursive) { ArrayList<File> files = new ArrayList<File>(); find(files, path, recursive); return files; } /*** * A private helper function for building the results for public Find. * @param files * @param path * @param recursive */ private static void find(List<File> files, File path, Boolean recursive) { if (path.isDirectory()) { // iterate over files for (File file : path.listFiles()) { if (recursive || !file.isDirectory()) { find(files, file, recursive); } } } else { // process the file files.add(path); } } }