Java Folder Visit deepListFilesVisitor(File file, FileFilter filter, boolean checkDir, List list)

Here you can find the source of deepListFilesVisitor(File file, FileFilter filter, boolean checkDir, List list)

Description

deep List Files Visitor

License

LGPL

Declaration

private static void deepListFilesVisitor(File file, FileFilter filter, boolean checkDir, List<File> list) 

Method Source Code


//package com.java2s;
/*/*from   www.j a  v a 2s  .c o m*/
 GNU LESSER GENERAL PUBLIC LICENSE
 Version 3, 29 June 2007
    
 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.
    
    
 This version of the GNU Lesser General Public License incorporates
 the terms and conditions of version 3 of the GNU General Public
 License
 */

import java.io.File;
import java.io.FileFilter;

import java.util.List;

public class Main {
    private static void deepListFilesVisitor(File file, FileFilter filter, boolean checkDir, List<File> list) {
        if (file.isDirectory()) {
            if (checkDir && filter != null && !filter.accept(file)) {
                return;
            }
            File[] files = file.listFiles();
            for (int i = 0; i < files.length; i++) {
                deepListFilesVisitor(files[i], filter, checkDir, list);
            }
        } else {
            if (filter == null || filter.accept(file)) {
                list.add(file);
            }
        }
    }
}

Related

  1. deepListFiles(File dir, FileFilter filter)
  2. deepListFiles(String sDir, String suffix)