Here you can find the source of getFilesIncludeSubdirectories(final File directory)
Parameter | Description |
---|---|
directory | File, directory |
public static List<File> getFilesIncludeSubdirectories(final File directory)
//package com.java2s; //License from project: LGPL import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { /**/*w ww. jav a 2 s .co m*/ * Get all files in directory and all subdirectories. * * @param directory * File, directory * @return List, list of all files */ public static List<File> getFilesIncludeSubdirectories(final File directory) { List<File> result = new ArrayList<File>(); getFilesIncludeSubdirectories(directory, result); return result; } /** * Get all files in directory and all subdirectories. * * @param directory * File, directory to search * @param list * List, list to store found files */ private static void getFilesIncludeSubdirectories(final File directory, List<File> list) { File[] fileList = directory.listFiles(); for (int i = 0; i < fileList.length; i++) { list.add(fileList[i]); if (fileList[i].isDirectory()) { getFilesIncludeSubdirectories(fileList[i], list); } } } }