All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.exlp.util.io.dir.RecursiveFileFinder Maven / Gradle / Ivy

The newest version!
package net.sf.exlp.util.io.dir;

import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.apache.commons.io.DirectoryWalker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class RecursiveFileFinder extends DirectoryWalker
{
	final static Logger logger = LoggerFactory.getLogger(RecursiveFileFinder.class);
	
	private FileFilter filter;
	
	public RecursiveFileFinder(FileFilter filter)
    {
		super();
		this.filter=filter;
    }

	public List find(File startDirectory) throws IOException
	{
		List results = new ArrayList();
		walk(startDirectory, results);
		return results;
    }
	
    protected boolean handleDirectory(File directory, int depth, Collection results)
    {
    	return true;
    }

    protected void handleFile(File file, int depth, Collection results)
    {
    	if(filter.accept(file))
    	{
    		results.add(file);
    	}
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy