org.aksw.commons.collections.FileDescender Maven / Gradle / Ivy
package org.aksw.commons.collections;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
/**
* @author Claus Stadler
*
* Date: 8/12/11
* Time: 5:17 PM
*/
public class FileDescender
implements Descender
{
private FileFilter filter;
public FileDescender() {
this.filter = new FileFilter() {
public boolean accept(File pathname) {
return true;
}};
}
public FileDescender(FileFilter filter) {
this.filter = filter;
}
@SuppressWarnings("unchecked")
public Collection getDescendCollection(File item) {
if(item == null || !item.isDirectory()) {
return new ArrayList();
}
File[] files = filter != null ? item.listFiles(filter) : item.listFiles();
Collection tmp = files == null ? Collections.emptyList() : Arrays.asList(files);
//System.out.println(tmp);
return new ArrayList(tmp);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy