List of utility methods to do File Find
List | find(File absolutePath, FileFilter filter) find files which has specified suffix. List<File> sourceFileList = new LinkedList<File>(); return addFoundFileToList(sourceFileList, absolutePath, filter); |
File | find(File baseFile, String regex) Find the file whose name matches the given regular expression. if (baseFile.getAbsolutePath().matches(regex)) { return baseFile; if (baseFile.exists() && baseFile.isDirectory()) { for (File child : listFiles(baseFile)) { File foundFile = find(child, regex); if (foundFile != null) { return foundFile; ... |
File | find(File dir, String baseName) Find a file starting with the baseName . if (dir == null) throw new IllegalArgumentException("directory can not be null"); if (baseName == null) throw new IllegalArgumentException("baseName can not be null"); File found = null; File[] files = dir.listFiles(); if (files != null) { for (File file : files) { ... |
List | find(File dir, String suffix, Set find List<File> lst = new ArrayList<File>(); for (String fn : dir.list()) { if (ignore.contains(fn)) { continue; File f = new File(dir, fn); if (f.isFile() && fn.endsWith(suffix)) { lst.add(f); ... |
List | find(File file) find return find(file, null);
|
void | find(File file, Pattern pattern, int limit, List find if (visited.contains(file)) throw new IOException("Circular file structure detected"); visited.add(file); if (limit > -1 && found.size() >= limit) return; if (file.isDirectory()) { File[] subFiles = file.listFiles(); Arrays.sort(subFiles); ... |
File | find(File folder, final String name) Find the File with the given name in the given folder, or its subfolders. if (name != null && name.length() > 0 && folder != null && folder.isDirectory()) { File[] files = folder.listFiles(new FileFilter() { @Override public boolean accept(File file) { return (file.isDirectory() || file.getName().equals(name)); }); for (File file : files) { ... |
ArrayList | find(File path, Boolean recursive) Return all files beneath path. ArrayList<File> files = new ArrayList<File>(); find(files, path, recursive); return files; |
List | find(File root) find if (!root.isDirectory()) throw new IllegalAccessError(root + " must be a folder."); List<File> klazzes = new ArrayList<File>(); addFiles(klazzes, root); return klazzes; |
File | find(final File fileDir, final String fileNameRegex) Find a file in a given directory with the specified regex pattern. File[] found = fileDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.matches(fileNameRegex); }); if (found != null && found.length != 0) { if (found.length == 1) { ... |