Example usage for org.apache.commons.io FileUtils listFiles

List of usage examples for org.apache.commons.io FileUtils listFiles

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils listFiles.

Prototype

public static Collection listFiles(File directory, String[] extensions, boolean recursive) 

Source Link

Document

Finds files within a given directory (and optionally its subdirectories) which match an array of extensions.

Usage

From source file:com.denimgroup.threadfix.framework.impl.dotNet.DotNetFrameworkChecker.java

@Nonnull
@Override/* www .j  av a2 s  .c  o m*/
public FrameworkType check(@Nonnull ProjectDirectory directory) {
    Collection csFiles = FileUtils.listFiles(directory.getDirectory(), new FileExtensionFileFilter("cs"),
            TrueFileFilter.INSTANCE);

    LOG.info("Got " + csFiles.size() + " .cs files from the directory.");

    Collection routeConfig = FileUtils.listFiles(directory.getDirectory(),
            new FileExtensionFileFilter("Controller.cs"), TrueFileFilter.INSTANCE);

    LOG.info("Got " + routeConfig.size() + " Controller files from the directory.");

    FrameworkType type = csFiles.isEmpty() || routeConfig.isEmpty() ? FrameworkType.NONE
            : FrameworkType.DOT_NET_MVC;

    return type;
}

From source file:com.legstar.cobc.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.
 *///www  . j av a 2s.co  m
protected void cleanOldReferences() {
    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();
        }
    }
}

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

private Collection<File> readJsonFiles(File collection) {
    Collection<File> files = FileUtils.listFiles(collection, new SuffixFileFilter(".json"),
            DirectoryFileFilter.DIRECTORY);
    System.out.println(files);/*from  www  .j  a va 2 s  .c o m*/
    return files;
}

From source file:de.brendamour.jpasskit.signing.PKPassTemplateFolderTest.java

@Test
public void provisionTest() throws IOException, URISyntaxException {
    File tempPassDir = Files.createTempDir();
    pkPassTemplateFolder.provisionPassAtDirectory(tempPassDir);

    RegexFileFilter regexFileFilter = new RegexFileFilter("^(.*?)");
    Collection<File> templateFiles = FileUtils.listFiles(new File(PASS_TEMPLATE_FOLDER), regexFileFilter,
            DirectoryFileFilter.DIRECTORY);
    Collection<File> createdFiles = FileUtils.listFiles(tempPassDir, regexFileFilter,
            DirectoryFileFilter.DIRECTORY);
    Assert.assertEquals(createdFiles.size(), templateFiles.size());
}

From source file:net.jakubholy.jeeutils.jsfelcheck.sourcefinder.FilesystemViewFinder.java

/** {@inheritDoc} */
public Collection<File> findViewFiles() {

    final Collection<File> allFiles = new LinkedList<File>();

    for (File searchRoot : searchRoots) {
        @SuppressWarnings("unchecked")
        Collection<File> viewFilesUnderRoot = FileUtils.listFiles(searchRoot, allowedExtensions, true);
        allFiles.addAll(viewFilesUnderRoot);
    }/*from   w w w  .  ja v a 2  s.  c o m*/

    return allFiles;
}

From source file:io.cloudslang.web.services.FlowsServiceImpl.java

@Override
public Collection<File> getCpFiles(String classpath) {
    String cp = getCp(classpath);
    return FileUtils.listFiles(new File(cp), CSLANG_FILE_EXTENSIONS, true);
}

From source file:com.admc.jcreole.CreoleParseTest.java

@Parameters
public static List<Object[]> creoleFiles() throws IOException {
    if (!pCreoleInRoot.isDirectory())
        throw new IllegalStateException("Dir missing: " + pCreoleInRoot.getAbsolutePath());
    if (!nCreoleInRoot.isDirectory())
        throw new IllegalStateException("Dir missing: " + nCreoleInRoot.getAbsolutePath());
    if (pWorkOutRoot.exists())
        FileUtils.deleteDirectory(pWorkOutRoot);
    pWorkOutRoot.mkdir();/*  w w w .j  av a2  s .c o  m*/
    if (nWorkOutRoot.exists())
        FileUtils.deleteDirectory(nWorkOutRoot);
    nWorkOutRoot.mkdir();
    List<Object[]> params = new ArrayList<Object[]>();
    File eFile;
    for (File f : FileUtils.listFiles(pCreoleInRoot, new String[] { "creole" }, true)) {
        eFile = new File(f.getParentFile(), f.getName().replaceFirst("\\..*", "") + ".html");
        params.add(new Object[] { f, eFile,
                (eFile.isFile()
                        ? new File(pWorkOutRoot,
                                f.getParentFile().equals(pCreoleInRoot) ? eFile.getName()
                                        : (f.getParent().substring(pCreoleInRootPath.length()) + FSEP
                                                + eFile.getName()))
                        : null),
                Boolean.TRUE });
    }
    String name;
    for (File f : FileUtils.listFiles(nCreoleInRoot, new String[] { "creole" }, true)) {
        name = f.getName().replaceFirst("\\..*", "") + ".html";
        params.add(new Object[] { f, null,
                new File(nWorkOutRoot,
                        f.getParentFile().equals(nCreoleInRoot) ? name
                                : (f.getParent().substring(nCreoleInRootPath.length()) + FSEP + name)),
                Boolean.FALSE });
    }
    return params;
}

From source file:fr.acxio.tools.agia.tasks.FileCopyTaskletTest.java

@After
public void tearDown() throws Exception {
    Collection<File> aFilesToDelete = FileUtils.listFiles(new File("target"),
            new WildcardFileFilter("input-copy*.csv"), null);
    for (File aFile : aFilesToDelete) {
        FileUtils.deleteQuietly(aFile);/* w w  w  . j a va2  s.co  m*/
    }
    FileUtils.deleteDirectory(new File("target/CP-testfiles"));
}

From source file:com.mohawk.webcrawler.lang.verb.GetUrl_Verb.java

@Override
public Object run(ScriptContext pageContext, Object... params) throws Exception {

    Object p1 = LangCore.resolveParameter(pageContext, params[0]);

    if (!(p1 instanceof String))
        throw new LanguageException("String literal required as parameter>> " + p1);

    String url = (String) p1;
    Document doc = null;// w  w w .j  a  va  2s. com

    Config config = pageContext.getConfig();

    if (config.getCacheDirectory() != null) { // pull the HTML from cache
        String prefix = null; //pageContext.getConfig().getProviderId() + "_";
        Collection<File> files = FileUtils.listFiles(
                new File("C:\\Users\\cnguyen\\Projects\\ProjectMohawk\\Scripts\\cache"), null, false);

        for (File file : files) {
            if (file.getName().startsWith(prefix)) {
                doc = Jsoup.parse(file, "UTF-8");
                break;
            }
        }
    } else {
        int MINS_2 = 2 * 60 * 1000;
        doc = (Document) Jsoup.parse(new URL(url), MINS_2);
    }

    // clear out any other contexts
    pageContext.setTableContext(null);
    pageContext.setDocument(doc);
    pageContext.setDocumentHtml(doc.html());
    pageContext.setCursorPosition(0);
    return null;

}

From source file:avantssar.aslanpp.testing.DiskSpecificationsProvider.java

public DiskSpecificationsProvider(String baseDirectory) {
    File base = new File(baseDirectory);
    if (!base.exists() || !base.isDirectory()) {
        throw new IllegalArgumentException(
                "Path '" + baseDirectory + "' cannot be accessed or does not point to a directory.");
    }/*from  w  ww .  ja v  a  2 s .com*/
    IOFileFilter filter = FileFilterUtils.suffixFileFilter(".aslan++");
    IOFileFilter dirFilter = FileFilterUtils.makeCVSAware(FileFilterUtils.makeSVNAware(null));
    Collection<File> specs = FileUtils.listFiles(base, filter, dirFilter);
    List<String> forSort = new ArrayList<String>();
    SortedSet<String> forASLanPath = new TreeSet<String>();
    for (File f : specs) {
        if (isSpec(f)) {
            forSort.add(f.getAbsolutePath());
            forASLanPath.add(f.getParent());
        }
    }
    Collections.sort(forSort);
    for (String s : forSort) {
        add(new DiskTestTask(new File(s)));
    }
    String temp = "";
    for (String s : forASLanPath) {
        if (temp.length() > 0) {
            temp += File.pathSeparator;
        }
        temp += s;
    }
    aslanPath = temp;
}