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.epam.wilma.gepard.test.sequence.handling.live.SequenceHandlingTestJsonToXml.java

/**
 * Test the sequence handling part by using sessions.
 *
 * @throws Exception in case of error/*w  w  w  . j  av a  2 s.  c o  m*/
 */
@Test
public void testSessionBasedSequence() throws Exception {
    String realTargetUrl = getWilmaInternalUrl() + TARGET_URL;
    clearSequences();
    setOperationModeTo("stub");
    turnOnSequenceHandling();
    setInterceptorModeTo("off");
    Collection<File> templateFiles = FileUtils.listFiles(new File("resources/sequence/live/newtemplates"),
            new String[] { "xml", "xsl", "json" }, false);
    for (File file : templateFiles) {
        uploadTemplateToWilma(file.getName(), file.getAbsolutePath());
    }
    uploadStubConfigToWilma(STUB_CONFIG_LOCATION);
    setExpectedResponseMessage("");
    RequestParameters one = createRequestParameters(JSON_REQUEST, "http://cica.fule.net/PancakeLand", "json");
    callWilmaWithPostMethod(one);
    RequestParameters two = createRequestParameters(ORIGINAL_REQUEST, realTargetUrl, "xml");
    callWilmaWithPostMethod(two);
    RequestParameters three = createRequestParameters(MAGIC_REQUEST, realTargetUrl, "xml");
    setExpectedResponseMessageFromFile(EXPECTED_RESPONSE_FILE);
    callWilmaWithPostMethodAndAssertResponse(three);
    setOperationModeTo("wilma");
}

From source file:com.epam.wilma.gepard.test.sequence.handling.live.SequenceHandlingTestXmlToXml.java

/**
 * Test the sequence handling part by using sessions.
 *
 * @throws Exception in case of error/* ww  w .j a v  a2 s . com*/
 */
@Test
public void testSessionBasedSequence() throws Exception {
    String realTargetUrl = getWilmaInternalUrl() + TARGET_URL;
    clearSequences();
    setOperationModeTo("stub");
    turnOnSequenceHandling();
    setInterceptorModeTo("off");
    Collection<File> templateFiles = FileUtils.listFiles(new File("resources/sequence/live/newtemplates"),
            new String[] { "xml", "xsl", "json" }, false);
    for (File file : templateFiles) {
        uploadTemplateToWilma(file.getName(), file.getAbsolutePath());
    }
    uploadStubConfigToWilma(STUB_CONFIG_LOCATION);
    setExpectedResponseMessage("");
    RequestParameters one = createRequestParameters(JSON_REQUEST, "http://cica.fule.net/PancakeLand", "json");
    callWilmaWithPostMethod(one);
    RequestParameters two = createRequestParameters(ORIGINAL_REQUEST, realTargetUrl, "xml");
    callWilmaWithPostMethod(two);
    RequestParameters three = createRequestParameters(MAGIC_REQUEST, realTargetUrl, "xml");
    setExpectedResponseMessage(EXPECTED_RESPONSE);
    callWilmaWithPostMethod(three);
    setOperationModeTo("wilma");
}

From source file:io.druid.segment.realtime.firehose.LocalFirehoseFactory.java

@Override
public Firehose connect(StringInputRowParser firehoseParser) throws IOException {
    log.info("Searching for all [%s] in and beneath [%s]", filter, baseDir.getAbsoluteFile());

    Collection<File> foundFiles = FileUtils.listFiles(baseDir.getAbsoluteFile(), new WildcardFileFilter(filter),
            TrueFileFilter.INSTANCE);/*  w  w w  .  j a  va  2  s .  c om*/

    if (foundFiles == null || foundFiles.isEmpty()) {
        throw new ISE("Found no files to ingest! Check your schema.");
    }
    log.info("Found files: " + foundFiles);

    final LinkedList<File> files = Lists.newLinkedList(foundFiles);

    return new FileIteratingFirehose(new Iterator<LineIterator>() {
        @Override
        public boolean hasNext() {
            return !files.isEmpty();
        }

        @Override
        public LineIterator next() {
            try {
                return FileUtils.lineIterator(files.poll());
            } catch (Exception e) {
                throw Throwables.propagate(e);
            }
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException();
        }
    }, firehoseParser);
}

From source file:CheckService.java

public void run() {
    Collection<File> bckIdxCollection = FileUtils.listFiles(repository.getMetaPath(),
            new WildcardFileFilter(bckIdxName), TrueFileFilter.INSTANCE);

    logger.info("check started for {} indexes.", bckIdxCollection.size());

    for (File fileIdx : bckIdxCollection) {
        try {//w  w w  . j  a  va2s  .  c om
            final VOBackupIndex voBackupIndex = repository.getVoBackupIndex(fileIdx);
            VOCheckIndex check = repository.checkIndex(voBackupIndex, false, false);

            if (check.allOk()) {
                logger.info("backup {} is OK", fileIdx.getName());
            } else {
                logger.error("check index {}: {}", fileIdx.getName(), check.toString());
            }
        } catch (Exception e) {
            logger.error("Cannot check index " + fileIdx.getAbsolutePath(), e);
        }
    }

    logger.info("check ended");
}

From source file:channellistmaker.listmaker.fileseeker.FileSeeker.java

/**
 * ???????/*from  ww  w.ja va 2  s  . co m*/
 *
 * @return ?????? ?????????null
 */
public synchronized List<File> seek() {
    if (this.SourceDir.isDirectory()) {
        List<File> list = Collections.synchronizedList(new ArrayList<File>());
        Collection<File> files = FileUtils.listFiles(this.SourceDir, this.seekType, this.dirf);
        list.addAll(files);
        return list;
    } else {
        return null;
    }
}

From source file:com.cisco.dbds.utils.configfilehandler.ConfigFileHandler.java

/**
 * Load config file./*w ww .  j  a v  a2  s  .c o m*/
 *
 * @param filepath the filepath
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static void loadConfigFile(String filepath) throws IOException {

    System.out.println("loadConfigFile inisde");
    //File dir = new File("src/it/resources");
    File dir = new File(filepath);
    String[] extensions = new String[] { "properties" };
    System.out.println("Getting all .properties files in " + dir.getCanonicalPath()
            + " including those in subdirectories");
    List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true);
    for (File file : files) {
        System.out.println("file: " + file.getCanonicalPath());
        FileInputStream fn = new FileInputStream(file.getCanonicalPath());
        setSystemvariable(fn);
        fn.close();
    }

}

From source file:com.liferay.maven.arquillian.internal.tasks.ToolsClasspathTask.java

@Override
public URLClassLoader execute(MavenWorkingSession session) {

    final Logger log = LoggerFactory.getLogger(ToolsClasspathTask.class);

    final ParsedPomFile pomFile = session.getParsedPomFile();

    LiferayPluginConfiguration configuration = new LiferayPluginConfiguration(pomFile);

    System.setProperty("liferayVersion", configuration.getLiferayVersion());

    File appServerLibGlobalDir = new File(configuration.getAppServerLibGlobalDir());

    File appServerLibPortalDir = new File(configuration.getAppServerLibPortalDir());

    List<URI> liferayToolArchives = new ArrayList<URI>();

    if (appServerLibGlobalDir != null && appServerLibGlobalDir.exists()) {

        // app server global libraries
        Collection<File> appServerLibs = FileUtils.listFiles(appServerLibGlobalDir, new String[] { "jar" },
                true);/*  w w w  .java 2 s . c  o m*/

        for (File file : appServerLibs) {
            liferayToolArchives.add(file.toURI());
        }

        // All Liferay Portal Lib jars
        Collection<File> liferayPortalLibs = FileUtils.listFiles(appServerLibPortalDir, new String[] { "jar" },
                true);

        for (File file : liferayPortalLibs) {
            liferayToolArchives.add(file.toURI());
        }

        // Util jars
        File[] utilJars = Maven.resolver().loadPomFromClassLoaderResource("liferay-tool-deps.xml")
                .importCompileAndRuntimeDependencies().resolve().using(AcceptAllStrategy.INSTANCE).asFile();

        for (int i = 0; i < utilJars.length; i++) {
            liferayToolArchives.add(utilJars[i].toURI());
        }

    }

    log.trace("Jars count in Tools classpath Archive:" + liferayToolArchives.size());

    List<URL> classpathUrls = new ArrayList<URL>();

    try {
        if (!liferayToolArchives.isEmpty()) {

            ListIterator<URI> toolsJarItr = liferayToolArchives.listIterator();
            while (toolsJarItr.hasNext()) {
                URI jarURI = toolsJarItr.next();
                classpathUrls.add(jarURI.toURL());
            }

        }
    } catch (MalformedURLException e) {
        log.error("Error building Tools classpath", e);
    }

    return new URLClassLoader(classpathUrls.toArray(new URL[classpathUrls.size()]), null);
}

From source file:com.evolveum.midpoint.tools.gui.PropertiesGenerator.java

private void cleanupTargetFolder(List<File> existingFiles, File target) throws IOException {
    Collection<File> files = FileUtils.listFiles(target, new String[] { "properties" }, true);

    for (File file : files) {
        if (existingFiles.contains(file)) {
            continue;
        }/*from   www. ja v a2s  .c o m*/
        System.out.println("File to be deleted: " + file.getAbsolutePath());

        if (!config.isDisableBackup()) {
            File backupFile = new File(target, file.getName() + ".backup");
            FileUtils.moveFile(file, backupFile);
        } else {
            file.delete();
        }
    }
}

From source file:com.denimgroup.threadfix.framework.impl.dotNetWebForm.WebFormsEndpointGenerator.java

private List<AspxCsParser> getAspxCsParsers(File rootDirectory) {
    Collection aspxCsFiles = FileUtils.listFiles(rootDirectory, new FileExtensionFileFilter(".cs"),
            TrueFileFilter.INSTANCE);//from  w  ww  .j a v a 2  s  .  c om

    List<AspxCsParser> aspxCsParsers = list();

    for (Object aspxCsFile : aspxCsFiles) {
        if (aspxCsFile instanceof File) {
            aspxCsParsers.add(AspxCsParser.parse((File) aspxCsFile));
        }
    }

    return aspxCsParsers;
}

From source file:com.epam.wilma.gepard.test.sequence.handling.live.SequenceHandlingTestXmlToJson.java

/**
 * Test the sequence handling part by using sessions.
 *
 * @throws Exception in case of error//from   w  w w  . ja v  a 2 s.c om
 */
@Test
public void testSessionBasedSequence() throws Exception {
    String realTargetUrl = getWilmaInternalUrl() + TARGET_URL;
    clearSequences();
    setOperationModeTo("stub");
    turnOnSequenceHandling();
    setInterceptorModeTo("off");
    Collection<File> templateFiles = FileUtils.listFiles(new File("resources/sequence/live/jsontemplates"),
            new String[] { "xml", "xsl", "json" }, false);
    for (File file : templateFiles) {
        uploadTemplateToWilma(file.getName(), file.getAbsolutePath());
    }
    uploadStubConfigToWilma(STUB_CONFIG_LOCATION);
    setExpectedResponseMessage("");
    RequestParameters two = createRequestParameters(ORIGINAL_REQUEST, realTargetUrl, "xml");
    callWilmaWithPostMethod(two);
    RequestParameters three = createRequestParameters(MAGIC_REQUEST, realTargetUrl, "xml");
    callWilmaWithPostMethod(three);
    RequestParameters one = createRequestParameters(JSON_REQUEST, "http://cica.fule.net/PancakeLand", "json");
    setExpectedResponseMessage(EXPECTED_RESPONSE);
    callWilmaWithPostMethodAndAssertResponse(one);
    setOperationModeTo("wilma");
}