List of usage examples for org.apache.commons.io FileUtils listFiles
public static Collection listFiles(File directory, String[] extensions, boolean recursive)
From source file:com.denimgroup.threadfix.framework.impl.rails.RailsControllerParser.java
public static Collection parse(@Nonnull File rootFile) { if (!rootFile.exists() || !rootFile.isDirectory()) { LOG.error("Root file not found or is not directory. Exiting."); return null; }/* w ww. j a va2 s. c o m*/ File ctrlDir = new File(rootFile, "app/controllers"); if (!ctrlDir.exists() || !ctrlDir.isDirectory()) { LOG.error("{rootFile}/app/controllers/ not found or is not directory. Exiting."); return null; } Collection<File> rubyFiles = (Collection<File>) FileUtils.listFiles(ctrlDir, new WildcardFileFilter("*_controller.rb"), TrueFileFilter.INSTANCE); RailsControllerParser parser = new RailsControllerParser(); parser.modelMap = RailsModelParser.parse(rootFile); parser.railsControllers = list(); for (File rubyFile : rubyFiles) { parser._continue = true; parser.tokenQueue = new ArrayDeque<String>(); parser.currentRailsController = null; parser.currentCtrlMethod = null; parser.currentParamName = null; EventBasedTokenizerRunner.runRails(rubyFile, parser); if (parser.currentRailsController != null && parser.currentCtrlMethod != null && parser.currentCtrlMethod.getMethodName() != null) { parser.currentRailsController.addControllerMethod(parser.currentCtrlMethod); } if (parser.currentRailsController != null && parser.currentRailsController.getControllerMethods() != null && parser.currentRailsController.getControllerMethods().size() > 0) { parser.currentRailsController.setControllerFile(rubyFile); parser.railsControllers.add(parser.currentRailsController); } } return parser.railsControllers; }
From source file:co.cask.cdap.internal.app.runtime.webapp.JarExploderTest.java
private void verifyA(File dest) throws Exception { Collection<File> files = FileUtils.listFiles(dest, new String[] { "txt" }, true); Assert.assertEquals(aFileContentMap.size(), files.size()); for (File f : files) { String name = f.getAbsolutePath().replaceFirst(dest.getAbsolutePath(), ""); name = name.startsWith("/") ? name.substring(1, name.length()) : name; String expected = aFileContentMap.get(name); Assert.assertNotNull(expected);//from www . ja v a 2 s .com String actual = Files.toString(f, Charsets.US_ASCII); Assert.assertEquals(expected, actual.trim()); } }
From source file:com.btisystems.pronx.ems.AppIntegrationTest.java
/** * Integration test to verify the generated code is as expected. A previous * known good baseline is used and generated code compared to that. * * @throws Exception//from w w w. ja v a 2 s . com */ @Test public void shouldGenerateExpectedModel() throws Exception { Collection<File> files = FileUtils.listFiles(new File(GENERATED_DIRECTORY), new String[] { "java", "xml" }, true); for (final File file : files) { try { if (file.getCanonicalPath().endsWith("xml")) { trimNotificationMeta(file); } FileAssert.assertEquals(new File(file.getCanonicalPath().replaceFirst("generated", "baseline")), file); } catch (ComparisonFailure fail) { System.out.println("Failure when comparing: " + file.getCanonicalPath()); failed = true; throw fail; } } }
From source file:com.legstar.clients.tests.AbstractITCase.java
/** * Create a Cargo web container deploying all war files. All dependencies go * to shared library. There is also an WMQ JNDI setup. * //from w ww . j a v a2s . c o m * @return a container ready to start */ @SuppressWarnings("unchecked") public InstalledLocalContainer getContainer() { Tomcat6xStandaloneLocalConfiguration configuration = new Tomcat6xStandaloneLocalConfiguration( "target/tomcat6x"); Collection<File> warFiles = FileUtils.listFiles(new File("target/dependency/cixsgen/war"), new String[] { "war" }, false); for (File warFile : warFiles) { configuration.addDeployable(new WAR(warFile.getAbsolutePath())); } Resource dsConnectionFactory = new Resource("ConnectionFactory", "com.ibm.mq.jms.MQQueueConnectionFactory"); dsConnectionFactory.getParameters().put("hostName", "mainframe"); dsConnectionFactory.getParameters().put("port", "1414"); dsConnectionFactory.getParameters().put("queueManager", "CSQ1"); dsConnectionFactory.getParameters().put("channel", "CLIENT.TO.CSQ1"); dsConnectionFactory.getParameters().put("transportType", "1"); configuration.addResource(dsConnectionFactory); configuration.addResource(getQueueResource("CicsARequestQueue", "CICSA.REQUEST.QUEUE")); configuration.addResource(getQueueResource("CicsAReplyQueue", "CICSA.REPLY.QUEUE")); configuration.addResource(getQueueResource("Cics01BridgeRequestQueue", "CICS01.BRIDGE.REQUEST.QUEUE")); configuration.addResource(getQueueResource("Cics01BridgeReplyQueue", "CICS01.BRIDGE.REPLY.QUEUE")); Tomcat6xInstalledLocalContainer webapp = new Tomcat6xInstalledLocalContainer(configuration); Collection<File> jarFiles = FileUtils.listFiles(new File("target/dependency/cixsgen/lib"), new String[] { "jar" }, false); for (File jarFile : jarFiles) { webapp.addSharedClasspath(jarFile.getAbsolutePath()); } webapp.addSharedClasspath(new File("target/dependency/cixsgen/conf").getAbsolutePath()); File wmqDir = new File(System.getenv("WMQ_HOME") + "/lib"); webapp.addSharedClasspath(new File(wmqDir, "com.ibm.mq.jar").getAbsolutePath()); webapp.addSharedClasspath(new File(wmqDir, "com.ibm.mqjms.jar").getAbsolutePath()); webapp.addSharedClasspath(new File(wmqDir, "dhbcore.jar").getAbsolutePath()); webapp.setHome(System.getenv("CATALINA_HOME")); webapp.setOutput("target/cargo" + getName() + ".log"); return webapp; }
From source file:com.github.davidcarboni.encryptedfileupload.EncryptedFileItemSerializeTest.java
@After public void tearDown() { for (File file : FileUtils.listFiles(REPO, null, true)) { System.out.println("Found leftover file " + file); }/*from w ww . j a v a 2s . c o m*/ REPO.delete(); assertFalse(REPO + " is not empty", REPO.exists()); }
From source file:com.stratio.explorer.reader.FileConfByNameFileLocator.java
/** * locate any file into tree folders.//from w w w .j a v a 2 s . c om * @param fileName file to search * @return String with path */ public String locate(String fileName, String extensionFile) { String result = ""; try { String[] extensions = new String[] { extensionFile }; FunctionalList<File, File> functional = new FunctionalList( new ArrayList<>(FileUtils.listFiles(folder, extensions, true))); List<File> files = functional.search(new SearchFileFunction(fileName + "." + extensionFile)); result = pathIfexistFiles(files); if (noRootFolder() && result.isEmpty()) { folder = new File(folder.getParent()); result = locate(fileName, extensionFile); } } catch (OutOfMemoryError e) { Logger.info("Too many files"); } return result; }
From source file:fr.acxio.tools.agia.alfresco.ContentFileDeleteWriterTest.java
@After public void tearDown() throws Exception { Collection<File> aFilesToDelete = FileUtils.listFiles(new File("target"), new WildcardFileFilter("content*.pdf"), null); for (File aFile : aFilesToDelete) { FileUtils.deleteQuietly(aFile);/*ww w . java2 s . co m*/ } }
From source file:cc.kave.commons.utils.exec.CompletionEventProcessor.java
private List<String> findAllZips(String dir) { List<String> zips = Lists.newLinkedList(); for (File f : FileUtils.listFiles(new File(dir), new String[] { "zip" }, true)) { zips.add(f.getAbsolutePath());// ww w . ja v a2 s .c o m } return zips; }
From source file:com.megatome.j2d.support.JavadocSupport.java
/** * Find the file to be used as the docset index and locate all Javadoc files to be indexed. * @param javadocDir Directory where the Javadoc is located * @return IndexData object//from w ww.j a va2s .c o m * @throws BuilderException * @see IndexData */ public static IndexData findIndexFile(File javadocDir) throws BuilderException { final IndexData indexData = new IndexData(); if (!javadocDir.exists() || !javadocDir.isDirectory()) { throw new BuilderException( String.format("%s does not exist, or is not a directory", javadocDir.getAbsolutePath())); } logVerbose("Looking for javadoc files"); String docsetIndexFile = "overview-summary.html"; if (!getFile(javadocDir, docsetIndexFile).exists()) { docsetIndexFile = null; } final File indexFilesDir = getFile(javadocDir, "index-files"); if (indexFilesDir.exists() && indexFilesDir.isDirectory()) { docsetIndexFile = (docsetIndexFile != null) ? docsetIndexFile : "index-1.html"; for (File f : FileUtils.listFiles(indexFilesDir, new String[] { "html" }, false)) { if (f.getName().startsWith("index-")) { indexData.addFileToIndex(f); } } } else if (getFile(javadocDir, "index-all.html").exists()) { docsetIndexFile = (docsetIndexFile != null) ? docsetIndexFile : "index-all.html"; indexData.addFileToIndex(getFile(javadocDir, "index-all.html")); } if (!indexData.hasFilesToIndex()) { throw new BuilderException(String.format( "Did not find any javadoc files. Make sure that %s is a directory containing javadoc", javadocDir.getAbsolutePath())); } indexData.setDocsetIndexFile(docsetIndexFile); logVerbose("Found javadoc files"); return indexData; }
From source file:com.meltmedia.cadmium.copyright.service.CopyrightConfigProcessor.java
@Override public void processFromDirectory(String metaDir) throws Exception { log.debug("Processing html files in '{}' for copyright update.", metaDir); ResourceHandler handler = injector.getInstance(ResourceHandler.class); log.trace("Got handler from injector. {}", handler); File contentDirectory = new File(metaDir).getAbsoluteFile().getParentFile(); if (contentDirectory.exists()) { log.trace("The contentDirectory '{}' exists.", contentDirectory); Collection<File> htmlFiles = FileUtils.listFiles(contentDirectory, new String[] { "html", "htm" }, true);//from w ww .j a va2s . co m log.debug("Found {} html files.", htmlFiles.size()); for (File htmlFile : htmlFiles) { log.trace("Processing {}", htmlFile); handler.handleFile(htmlFile); } } }