Example usage for org.apache.commons.io.filefilter DirectoryFileFilter INSTANCE

List of usage examples for org.apache.commons.io.filefilter DirectoryFileFilter INSTANCE

Introduction

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

Prototype

IOFileFilter INSTANCE

To view the source code for org.apache.commons.io.filefilter DirectoryFileFilter INSTANCE.

Click Source Link

Document

Singleton instance of directory filter.

Usage

From source file:net.orpiske.ssps.sdm.main.PluginRepositoryHelper.java

public static void addToGroovyClasspath(File pluginDir) {
    GroovyClasspathHelper helper = GroovyClasspathHelper.getInstance();

    if (pluginDir.exists()) {

        File pluginRepositories[] = pluginDir.listFiles((FileFilter) DirectoryFileFilter.INSTANCE);

        for (File pluginRepository : pluginRepositories) {
            helper.addClasspath(pluginRepository.getPath());
        }//from   w w  w.j av a2s  .  c o m
    }
}

From source file:cop.raml.processor.AbstractProcessorTest.java

protected static boolean runAnnotationProcessor(File dir) throws URISyntaxException {
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    Set<JavaFileObject> compilationUnits = new LinkedHashSet<>();

    for (File file : (List<File>) FileUtils.listFiles(dir, JAVA_FILE_FILTER, DirectoryFileFilter.INSTANCE))
        compilationUnits.add(new SimpleJavaFileObjectImpl(file, JavaFileObject.Kind.SOURCE));

    List<String> options = new ArrayList<>();
    //        options.put("-Apackages=com.bosch");
    //        options.put("-AfilterRegex=AnalysisController");
    //        options.put("-Aversion=0.8");
    options.add("-d");
    options.add("target");

    JavaCompiler.CompilationTask task = compiler.getTask(null, null, null, options, null, compilationUnits);
    task.setProcessors(Collections.singleton(new RestProcessor()));

    return task.call();
}

From source file:com.opensearchserver.hadse.index.IndexCatalog.java

public final static void loadAll() {
    if (Hadse.data_dir == null)
        return;/*from   www  . j  a  v a  2s.c  om*/
    if (!(Hadse.data_dir.isDirectory()))
        return;
    File[] indexList = Hadse.data_dir.listFiles((FileFilter) DirectoryFileFilter.INSTANCE);
    if (indexList == null)
        return;
    for (File indexDirectory : indexList) {
        IndexItem indexItem = IndexItem.get(indexDirectory.getName());
        indexItem.load();
    }
}

From source file:net.orpiske.ssps.common.repository.search.FileSystemRepositoryFinder.java

public FileSystemRepositoryFinder() {
    String path = RepositoryUtils.getUserRepository();
    File repositoryRoot = new File(path);

    File[] allRepositories = repositoryRoot.listFiles((FileFilter) DirectoryFileFilter.INSTANCE);

    for (File repository : allRepositories) {
        search(repository);/*from   ww w .ja  v a 2s  .  c om*/
    }
}

From source file:com.thruzero.common.core.fs.FileListVisitorTest.java

@Test
public void testListOfSimpleDirectory() {
    // get test file in temp directory
    File nestedTestDir = getTestFile(NESTED_TEST_DIR_NAME);

    // walk the temp directory
    try {//from  w  w  w  .  ja v  a 2s  .c  o  m
        // find files named "*test*", using FileListVisitor
        FileAndDirectoryFilter filter = new FileAndDirectoryFilter(DirectoryFileFilter.INSTANCE,
                new WildcardFilter("*test*"));
        FileListStatus listingStatus = (FileListStatus) new HierarchicalFileWalker(nestedTestDir, filter)
                .accept(new FileListVisitor());
        assertEquals("Wrong number of files were found.", 5, listingStatus.getNumProcessed());
        assertEquals("Wrong number of files were found.", 5, listingStatus.getResults().size());
    } catch (IOException e) {
        fail("FileListFileWalker generated exception: " + e);
    }
}

From source file:com.discursive.jccook.io.FilterExample.java

public void start() {
    File rootDir = new File(".");
    FilenameFilter fileFilter = new SuffixFileFilter(".xml");
    String[] xmlFiles = rootDir.list(fileFilter);
    System.out.println("*** XML Files");
    System.out.println(ArrayUtils.toString(xmlFiles));

    rootDir = new File("./test");

    IOFileFilter htmlFilter = new OrFileFilter(new SuffixFileFilter("htm"), new SuffixFileFilter("html"));
    IOFileFilter notDirectory = new NotFileFilter(DirectoryFileFilter.INSTANCE);
    fileFilter = new AndFileFilter(htmlFilter, notDirectory);

    String[] htmlFiles = rootDir.list(fileFilter);
    System.out.println("*** HTML Files");
    System.out.println(ArrayUtils.toString(htmlFiles));
}

From source file:gr.aueb.mipmapgui.controller.file.ActionInitialize.java

private void getSavedUserFiles(String user) {
    JSONArray taskFileArr = new JSONArray();

    ActionCreateUserDirectory actionCreateUserDirectory = new ActionCreateUserDirectory(modello);
    actionCreateUserDirectory.performAction(user);
    ActionCleanDirectory actionCleanDirectory = new ActionCleanDirectory(modello);
    actionCleanDirectory.performAction(user);

    File tasksDir = new File(Costanti.SERVER_MAIN_FOLDER + Costanti.SERVER_FILES_FOLDER + user + "/");
    String[] taskFiles = tasksDir.list(DirectoryFileFilter.INSTANCE);
    for (String file : taskFiles) {
        if (!file.equalsIgnoreCase("temp")) {
            taskFileArr.add(file);/*from  w  w  w  . ja  v  a 2 s .  com*/
        }
    }
    JSONObject.put("savedTasks", taskFileArr);
}

From source file:com.thruzero.common.core.fs.FileRenamingVisitorTest.java

@Test
public void testRenameOfSimpleDirectory() {
    // clean the temp directory
    deleteTempDirContents();/*  w w w  . j  av  a2  s . c o  m*/

    // copy test directory to a temp directory, as a rename target
    File renamingTestDir = copyDirToTemp(RENAMING_TEST_DIR_NAME);

    // walk the temp directory
    try {
        // rename the files and verify
        SubstitutionStrategy strategy = new KeyValuePairSubstitutionStrategy(
                new KeyValuePair("${sub1}", SUBSTITUTION_ONE_VALUE));
        FileWalkerStatus renamingStatus = new HierarchicalFileWalker(renamingTestDir, null)
                .accept(new FileRenamingVisitor(strategy));
        assertEquals("Wrong number of files/directories were renamed.", 4, renamingStatus.getNumProcessed());

        // verify files were renamed, using FileListFileWalker
        FileAndDirectoryFilter filter = new FileAndDirectoryFilter((FileFilter) DirectoryFileFilter.INSTANCE,
                new WildcardFilter("*" + SUBSTITUTION_ONE_VALUE + "*"));
        FileWalkerStatus listingStatus = new HierarchicalFileWalker(renamingTestDir, filter)
                .accept(new FileListVisitor());
        assertEquals("Wrong number of files were renamed.", 3, listingStatus.getNumProcessed()); // 3 files should be renamed (plus one directory that's not
                                                                                                 // sslisted here)
    } catch (IOException e) {
        fail("FileRenamingFileWalker generated exception: " + e);
    }
}

From source file:com.nabla.dc.server.MyReadWriteDatabase.java

@Inject
public MyReadWriteDatabase(final ServletContext serverContext, final ReportManager reportManager)
        throws SQLException, DispatchException {
    super("dcrw", serverContext, IRoles.class, serverContext.getInitParameter("root_password"));

    if ("1".equals(serverContext.getInitParameter(PRODUCTION_MODE))) {
        if (log.isDebugEnabled())
            log.debug("loading internal report table");
        final Connection conn = getConnection();
        try {//from ww w.jav  a2 s.c  o  m
            final ConnectionTransactionGuard guard = new ConnectionTransactionGuard(conn);
            try {
                Database.executeUpdate(conn, "DELETE FROM report WHERE internal_name IS NOT NULL;");
                final File reportFolder = new File(
                        serverContext.getRealPath(ReportManager.INTERNAL_REPORT_FOLDER));
                for (File folder : reportFolder.listFiles((FileFilter) DirectoryFileFilter.INSTANCE))
                    loadInternalReport(conn, folder, reportManager);
                guard.setSuccess();
            } finally {
                guard.close();
            }
        } finally {
            conn.close();
        }
    }
}

From source file:com.legstar.protobuf.cobol.AbstractTest.java

/**
 * This is our chance to remove reference files that are no longer used by a
 * test case. This happens when test cases are renamed or removed.
 * /*from  w w w. ja  va2s. co  m*/
 * @throws IOException
 */
protected void cleanOldReferences() throws IOException {
    if (!getReferenceFolder().exists()) {
        return;
    }
    Method[] methods = getClass().getDeclaredMethods();

    for (File refFile : FileUtils.listFiles(getReferenceFolder(), new String[] { REF_FILE_EXT }, false)) {
        boolean found = false;
        for (int i = 0; i < methods.length; i++) {
            if (methods[i].getName().equals(FilenameUtils.getBaseName(refFile.getName()))) {
                found = true;
                break;
            }
        }
        if (!found) {
            refFile.delete();
        }
    }
    String[] dirs = getReferenceFolder().list(DirectoryFileFilter.INSTANCE);
    for (String dir : dirs) {
        boolean found = false;
        for (int i = 0; i < methods.length; i++) {
            if (methods[i].getName().equals(dir)) {
                found = true;
                break;
            }
        }
        if (!found && !dir.equals(".svn")) {
            FileUtils.deleteDirectory(new File(getReferenceFolder(), dir));
        }
    }

}