List of utility methods to do Directory to File List
List | getAllFilesIn(File dir, final String type) get All Files In return Arrays.asList(dir.listFiles(new FilenameFilter() { @Override public boolean accept(File arg0, String arg1) { return arg1.endsWith(type); })); |
List | getAllFilesInAllSubDirectories(File parentDir, FileFilter filter) Returns all the files that satisfy the filter criteria wherever (in any replace-directory) they are inside this folder List<File> filesList = null;
return getAllFilesInAllSubDirectories(filesList, parentDir, filter);
|
List | getAllFilesInDir(boolean traverseSubDirs, File dir, boolean includeHidden, String prefix) get All Files In Dir List<String> files = new ArrayList<String>(); String fileNames[] = dir.list(); for (String fileName : fileNames) { File currentFile = new File(dir, fileName); if (currentFile.isHidden() && !includeHidden) { continue; if (currentFile.isDirectory()) { ... |
List | getAllFilesInDirectory(File dir) get All Files In Directory return getAllFilesInDirectory(dir, true);
|
void | getAllFilesInDirectory(File directory, List get All Files In Directory File[] fList = directory.listFiles(); for (File f : fList) { if (f.isFile()) { files.add(f); } else if (f.isDirectory()) { getAllFilesInDirectory(f, files); |
List | getAllFilesInDirectory(String directoryPath) get All Files In Directory return getAllFilesInDirectory(directoryPath, null);
|
List | getAllFilesInDirectory(String dirName) get All Files In Directory File folder = new File(dirName); File[] listOfFiles = folder.listFiles(); List<File> result = new ArrayList<>(); for (int i = 0; i < listOfFiles.length; i++) { if (listOfFiles[i].isFile()) { result.add(listOfFiles[i]); return result; |
File[] | getAllFilesInDirectory(String path) Returns the entire contents of a folder. File folder = new File(path); if (folder.exists()) { return folder.listFiles(); return null; |
List | getAllFilesInDirMatchingPattern(String directory, final String regex, final boolean first_match2) get All Files In Dir Matching Pattern File directoryFile = new File(directory); checkDirectory(directoryFile); FilenameFilter fileFilter = new FilenameFilter() { private boolean matchedyet = false; public boolean accept(File dir, String name) { if (first_match2 && matchedyet) return false; else { ... |
List | getAllFilesInFolder(File rootFolder, FileFilter filter, int maxFilesRequired) Retrieves a List with at most maxFiles files that are in a folder or any of the subfolders in that folder satisfying a condition. List<File> finalFiles = new ArrayList<>(); if (!Thread.currentThread().isInterrupted()) { if (maxFilesRequired < 0) throw new IllegalArgumentException("maxFilesRequired argument less than zero"); if (rootFolder == null || filter == null) throw new IllegalArgumentException("folder or filter null"); if (!rootFolder.exists() || !rootFolder.isDirectory()) throw new IllegalArgumentException("rootFolder argument is not a directory"); ... |