Java Recursive List recursiveList(File dir, FilenameFilter filter)

Here you can find the source of recursiveList(File dir, FilenameFilter filter)

Description

recursive List

License

Open Source License

Declaration

public static File[] recursiveList(File dir, FilenameFilter filter) 

Method Source Code


//package com.java2s;
/*//from ww w  .  jav  a 2s .  c o m
 * Copyright 2002 Felix Pahl. All rights reserved.
 * Use is subject to license terms.
 */

import java.io.File;

import java.io.FilenameFilter;

import java.util.Vector;

public class Main {
    public static File[] recursiveList(File dir, FilenameFilter filter) {
        Vector v = new Vector();
        addRecursiveList(dir, filter, v);
        File[] files = new File[v.size()];
        v.copyInto(files);
        return files;
    }

    public static void addRecursiveList(File dir, FilenameFilter filter, Vector v) {
        if (dir.isDirectory()) {
            String[] list = dir.list(filter);
            for (int i = 0; i < list.length; i++)
                addRecursiveList(new File(dir, list[i]), filter, v);
        } else
            v.add(dir);
    }
}

Related

  1. recursiveListFile(File folder)
  2. recursiveListFiles(File baseDir, final FileFilter filter)
  3. recursiveListFiles(File dir, FileFilter filter)
  4. recursiveListFiles(File file, List files)