Here you can find the source of recursiveListint(List
Parameter | Description |
---|---|
list | The list of the files. |
file | The file that is added to the list of files or a directory whose files will be added to the list. |
filter | The filter that it is used to filter the files from the directory. |
private static void recursiveListint(List<File> list, File file, FilenameFilter filter)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FilenameFilter; import java.util.List; public class Main { /**//from w ww. j a v a 2 s . c om * If the parameter file is a file then it is added to the * list of files. If it is a directory, it adds its contents recursively. * In case a filter is provided, the files from the directory have * to satisfy that filter. * * @param list * The list of the files. * @param file * The file that is added to the list of files or a * directory whose files will be added to the list. * @param filter * The filter that it is used to filter the files * from the directory. * */ private static void recursiveListint(List<File> list, File file, FilenameFilter filter) { if (file.isFile()) { list.add(file); } else { File[] children = null; if (filter != null) { children = file.listFiles(filter); } else { children = file.listFiles(); } for (File child : children) { if (child.isFile()) { list.add(child); } else { recursiveListint(list, child, filter); } } } } }