Example usage for org.apache.commons.io.filefilter FileFilterUtils directoryFileFilter

List of usage examples for org.apache.commons.io.filefilter FileFilterUtils directoryFileFilter

Introduction

In this page you can find the example usage for org.apache.commons.io.filefilter FileFilterUtils directoryFileFilter.

Prototype

public static IOFileFilter directoryFileFilter() 

Source Link

Document

Returns a filter that checks if the file is a directory.

Usage

From source file:de.fau.osr.util.VisibleFilesTraverser.java

/**
 * Builds a *VisibleFilesTraverser*./* w w w  .  j  a  v  a2s .co  m*/
 * @param startDirectory
 * @param ignoreFileNames
 * @return
 */
public static VisibleFilesTraverser Get(Path startDirectory, String... ignoreFileNames) {
    return new VisibleFilesTraverser(startDirectory, ignoreFileNames, FileFilterUtils.or(
            // Show visible directories
            FileFilterUtils.and(FileFilterUtils.directoryFileFilter(), HiddenFileFilter.VISIBLE),
            // Show visible files
            FileFilterUtils.and(FileFilterUtils.fileFileFilter(), HiddenFileFilter.VISIBLE)));
}

From source file:jackrabbit.repository.FileRepositorySourceTest.java

@Test
public void testGetSources() {
    File source = new File("/tmp");
    IOFileFilter filter = FileFilterUtils.directoryFileFilter();
    RepositorySource rs = new FileRepositorySource(source, filter);
    for (String file : rs.getSources()) {
        log.info(file);/*from w  w w  .ja  v  a 2s  .c om*/
    }
}

From source file:jackrabbit.repository.FileRepositorySource.java

public String[] getSources() {
    if (file.isDirectory()) {
        if (filter == null) //this is a repository directory
            return new String[] { file.getPath() };
        List<String> files = new ArrayList<String>();
        for (String f : file.list(FileFilterUtils.directoryFileFilter())) {
            files.add(file.getPath() + "/" + f);
        }//www .  java2 s  . c  o m
        return files.toArray(new String[0]);
    }
    return new String[] {};
}

From source file:net.landora.videoplayer.files.GeneralDirectoryMenu.java

@Override
protected void refreshImpl() {
    links = new ArrayList<MenuLink>();

    File[] children = dir.listFiles((FileFilter) FileFilterUtils.directoryFileFilter());
    if (children != null && children.length > 0) {
        Arrays.sort(children, new FileSorter());
        for (File child : children) {
            links.add(new MenuLink(Icon.Folder, child.getName(), new GeneralDirectoryMenu(child)));
        }//from w w w.  j  a v a  2s.  com
    }

    children = dir.listFiles((FileFilter) FileFilterUtils.notFileFilter(FileFilterUtils.directoryFileFilter()));
    if (children != null & children.length != 0) {
        Arrays.sort(children, new FileSorter());

        for (File child : children) {
            if (child.isHidden() || !child.isFile() || !ExtensionUtils.isVideoExtension(child)) {
                continue;
            }

            links.add(new MenuLink(Icon.File, child.getName(), new PlayFileAction(child)));
        }
    }
}

From source file:com.moneydance.modules.features.importlist.io.DirectoryValidator.java

@Override
public boolean accept(final File file) {
    try {//  w  ww. j  a v  a  2  s.  c om
        return FileFilterUtils.and(CanReadFileFilter.CAN_READ, FileFilterUtils.directoryFileFilter())
                .accept(file);
    } catch (SecurityException e) {
        LOG.log(Level.WARNING, e.getMessage(), e);
        return false;
    }
}

From source file:com.seyren.integrationtests.mongo.MongoDbIT.java

private File[] readCollectionDirectory() {
    return new File(this.getClass().getResource(".").getPath())
            .listFiles((FileFilter) FileFilterUtils.directoryFileFilter());
}

From source file:com.ning.metrics.collector.hadoop.processing.LocalSpoolManager.java

public static Collection<File> findOldSpoolDirectories(final String basePath, final long cutoff) {
    final Collection<File> files = new java.util.LinkedList<File>();
    // Candidates ("old") directories are the ones last modified more than 2 hours ago
    final File[] found = new File(basePath)
            .listFiles((FileFilter) FileFilterUtils.and(FileFilterUtils.directoryFileFilter(),
                    FileFilterUtils.ageFileFilter(System.currentTimeMillis() - cutoff, true)));

    // Can't use FileUtils.listFiles as it doesn't yield directories
    if (found != null) {
        for (final File file : found) {
            if (file.isDirectory()) {
                files.add(file);/* www  . j a v  a  2  s .c om*/
            }
        }
    }

    return files;
}

From source file:lineage2.commons.data.xml.AbstractDirParser.java

/**
 * Method parse./*ww w  .  j  a  va  2  s  . co m*/
 */
@Override
protected final void parse() {
    File dir = getXMLDir();

    if (!dir.exists()) {
        warn("Dir " + dir.getAbsolutePath() + " not exists");
        return;
    }

    File dtd = new File(dir, getDTDFileName());
    if (!dtd.exists()) {
        info("DTD file: " + dtd.getName() + " not exists.");
        return;
    }

    initDTD(dtd);

    try {
        Collection<File> files = FileUtils.listFiles(dir, FileFilterUtils.suffixFileFilter(".xml"),
                FileFilterUtils.directoryFileFilter());

        for (File f : files) {
            if (!f.isHidden()) {
                if (!isIgnored(f)) {
                    try {
                        parseDocument(new FileInputStream(f), f.getName());
                    } catch (Exception e) {
                        info("Exception: " + e + " in file: " + f.getName(), e);
                    }
                }
            }
        }
    } catch (Exception e) {
        warn("Exception: " + e, e);
    }
}

From source file:it.geosolutions.tools.io.file.FileRemover.java

public static List<File> collectOlder(final long time, final int daysAgo, final File root) {
    if (daysAgo < 0) {
        return null;
    }// w w w . jav a  2 s . c  o  m
    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(time);
    int days = cal.get(Calendar.DAY_OF_YEAR);
    if (days >= daysAgo)
        cal.set(Calendar.DAY_OF_YEAR, days - daysAgo);
    else {
        // TODO use getActualMaximum for days
        cal.set(Calendar.DAY_OF_YEAR, (354 + (days - daysAgo)));
        cal.set(Calendar.YEAR, cal.get(Calendar.YEAR) - 1);
    }
    // cal.getTime().toString()
    final Collector coll = new Collector(FileFilterUtils.andFileFilter(FileFilterUtils.directoryFileFilter(),
            FileFilterUtils.ageFileFilter(cal.getTime(), true)), 1);
    return coll.collect(root);
}

From source file:lineage2.gameserver.skills.SkillsEngine.java

/**
 * Method loadAllSkills./*from  w  w w . j  av a 2 s .c om*/
 * @return Map<Integer,Skill>
 */
public Map<Integer, Skill> loadAllSkills() {
    File dir = new File(Config.DATAPACK_ROOT, "data/xml/stats/skills");
    if (!dir.exists()) {
        _log.info("Dir " + dir.getAbsolutePath() + " not exists");
        return Collections.emptyMap();
    }
    Collection<File> files = FileUtils.listFiles(dir, FileFilterUtils.suffixFileFilter(".xml"),
            FileFilterUtils.directoryFileFilter());
    Map<Integer, Skill> result = new HashMap<>();
    int maxId = 0, maxLvl = 0;
    for (File file : files) {
        List<Skill> s = loadSkills(file);
        if (s == null) {
            continue;
        }
        for (Skill skill : s) {
            result.put(SkillTable.getSkillHashCode(skill), skill);
            if (skill.getId() > maxId) {
                maxId = skill.getId();
            }
            if (skill.getLevel() > maxLvl) {
                maxLvl = skill.getLevel();
            }
        }
    }
    _log.info("SkillsEngine: Loaded " + result.size() + " skill templates from XML files. Max id: " + maxId
            + ", max level: " + maxLvl);
    return result;
}