Android Utililty Methods Directory Search

List of utility methods to do Directory Search


The list of methods to do Directory Search are organized into topic(s).


Vectorfind(File pDirectory, String pRegex)
find all files in pDirectory and its sub directories whose absolute path matches pRegex
Vector<File> lReturn = new Vector<File>();
lReturn = find(lReturn, pDirectory, new RegExpFileFilter(pRegex));
return lReturn;
File[]findFiles(File dir, FileFilter filter)
Finds all files (non-recursively) in a directory based on the FileFilter.
if (!dir.exists()) {
    throw new FileNotFoundException("Directory " + dir
            + " does not exist.");
if (!dir.isDirectory()) {
    throw new FileNotFoundException("File " + dir
            + " is not a directory.");
ArrayList<File> files = new ArrayList<File>();
File[] allFiles = dir.listFiles();
if (allFiles != null && allFiles.length > 0) {
    for (File f : allFiles) {
        if (f.isFile()) {
            if (filter.accept(f)) {
File[] r = files.toArray(new File[0]);
return r;
StringrecursiveSearch( dir, String fileName)
Recursive method for searching file path.
for (String name : dir.list()) { file = new
            + "/" + name);
    if (name.compareTo(fileName) == 0)
        return file.getAbsolutePath();
    if (file.isDirectory()) {
        String filePath = recursiveSearch(file, fileName);
        if (filePath != null)