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.jsp.JSPMappings.java
@SuppressWarnings("unchecked") public JSPMappings(@Nonnull File rootFile) { if (rootFile.exists()) { this.projectRoot = rootFile; projectDirectory = new ProjectDirectory(rootFile); String jspRootString = CommonPathFinder.findOrParseProjectRootFromDirectory(rootFile, "jsp"); LOG.info("Calculated JSP root to be: " + jspRootString); if (jspRootString == null) { jspRoot = projectRoot;/*from ww w .j a v a 2s .c om*/ } else { jspRoot = new File(jspRootString); } Collection<File> jspFiles = FileUtils.listFiles(rootFile, JSPFileFilter.INSTANCE, NoDotDirectoryFileFilter.INSTANCE); LOG.info("Found " + jspFiles.size() + " JSP files."); for (File file : jspFiles) { parseFile(file); } addParametersFromIncludedFiles(); } else { LOG.error("Root file didn't exist. Exiting."); projectDirectory = null; projectRoot = null; jspRoot = null; } }
From source file:com.legstar.coxb.gen.CoxbBindingGeneratorTest.java
/** * Test all standard cases./* w w w .j a v a 2s. c o m*/ * * @throws Exception if generation fails */ public void testAllStandard() throws Exception { Collection<File> xsdFiles = FileUtils.listFiles(COB_XSD_DIR, new String[] { "xsd" }, false); for (File schemaFile : xsdFiles) { if (!NON_STANDARD_XSDS.contains(schemaFile.getName())) { genSourceAndCheck(schemaFile, "Dfhcommarea"); } } }
From source file:acmi.l2.clientmod.l2resources.Environment.java
public Stream<File> listFiles() { return paths.stream().flatMap(s -> { File file = new File(startDir, s); File parent = file.getParentFile(); if (!parent.exists()) return Stream.empty(); return FileUtils.listFiles(file.getParentFile(), new WildcardFileFilter(file.getName()), null).stream(); });//from w ww . ja va2 s .c om }
From source file:libepg.ts.fileseeker.TsFileSeeker.java
/** * ???????//from w w w .j a v a 2s . c om * * @return ?????? */ public synchronized List<File> seek() { List<File> list = Collections.synchronizedList(new ArrayList<File>()); Collection<File> files = FileUtils.listFiles(this.SourceDir, this.TS_SUFFIX, this.dirf); list.addAll(files); return Collections.unmodifiableList(list); }
From source file:com.kelveden.rastajax.cli.Runner.java
private static List<URL> getClasspathURLs(File workingDirectory) throws CliExecutionException { final File classesFolder = new File(workingDirectory, "WEB-INF/classes"); final File libFolder = new File(workingDirectory, "WEB-INF/lib"); final List<URL> urls = new ArrayList<URL>(); try {/* w w w . j a v a 2 s. com*/ urls.add(classesFolder.toURI().toURL()); } catch (final MalformedURLException e) { throw new CliExecutionException("Could not get the URL for '" + classesFolder.getAbsolutePath() + "'.", e); } for (File file : FileUtils.listFiles(libFolder, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { try { urls.add(file.toURI().toURL()); } catch (final MalformedURLException e) { throw new CliExecutionException("Could not get the URL for '" + file.getAbsolutePath() + "'.", e); } } return urls; }
From source file:com.infosupport.ellison.sonarplugin.HTMLSourceImporter.java
/** * This method is called to add the HTML source files to Sonar's backend. See the documentation of the superclass * for more information.// ww w.j a v a 2s . c o m * * @param project * the project for which this method will be importing HTML source files * @param context * the context in which this method has been called * * @see AbstractSourceImporter#analyse(org.sonar.api.resources.Project, org.sonar.api.batch.SensorContext) */ @Override public void analyse(Project project, SensorContext context) { ProjectFileSystem fileSystem = project.getFileSystem(); List<File> sourceDirs = new ArrayList<>(); sourceDirs.addAll(fileSystem.getSourceDirs()); File webAppDir = new File(fileSystem.getBasedir(), "src/main/webapp"); if (webAppDir.exists()) { sourceDirs.add(webAppDir); } List<File> htmlFiles = new ArrayList<>(); for (File sourceDir : sourceDirs) { htmlFiles.addAll(FileUtils.listFiles(sourceDir, HTML_EXTENSIONS, true)); } for (File htmlFile : htmlFiles) { Resource htmlResource = createResource(htmlFile, sourceDirs, false); String htmlSource = null; try { htmlSource = FileUtils.readFileToString(htmlFile); } catch (IOException e) { LOGGER.warn("Could not read HTML file", e); return; } context.saveSource(htmlResource, htmlSource); } onFinished(); }
From source file:it.marcoberri.mbmeteo.action.Commons.java
/** * * @param log//from w w w . ja v a 2 s. com */ public static void importLogEasyWeather(Logger log) { try { final File importPath = new File( ConfigurationHelper.prop.getProperty("import.loggerEasyWeather.filepath")); FileUtils.forceMkdir(importPath); final File importPathBackup = new File( ConfigurationHelper.prop.getProperty("import.loggerEasyWeather.filepath") + File.separator + "old" + File.separator); FileUtils.forceMkdir(importPathBackup); boolean hasHeader = Default .toBoolean(ConfigurationHelper.prop.getProperty("import.loggerEasyWeather.hasHeader"), true); final String[] extension = { "csv", "txt" }; Collection<File> files = FileUtils.listFiles(importPath, extension, false); if (files.isEmpty()) { log.debug("No file to inport: " + importPath); return; } for (File f : files) { log.debug("read file:" + f); final List<String> l = FileUtils.readLines(f, "UTF-8"); log.debug("tot line:" + l.size()); final Datastore ds = MongoConnectionHelper.ds; log.debug("hasHeader: " + hasHeader); int lineCount = 0; int lineDouble = 0; for (String s : l) { if (hasHeader) { hasHeader = false; continue; } final String[] columns = s.split(";"); List<Meteolog> check = ds.createQuery(Meteolog.class).field("time") .equal(getDate("dd-MM-yyyy HH:mm", columns[1], log)).asList(); if (check != null && !check.isEmpty()) { log.debug("data exist, continue"); lineDouble++; continue; } final Meteolog meteoLog = new Meteolog(); try { meteoLog.setN(Integer.valueOf(columns[0])); } catch (Exception e) { log.error("line skipped " + lineCount, e); continue; } try { meteoLog.setTime(getDate("dd-MM-yyyy HH:mm", columns[1], log)); } catch (Exception e) { log.error("line skipped" + lineCount, e); continue; } try { meteoLog.setInterval(Integer.valueOf(columns[2])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setIndoorHumidity(Double.valueOf(columns[3])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setIndoorTemperature(Double.valueOf(columns[4])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setOutdoorHumidity(Double.valueOf(columns[5])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setOutdoorTemperature(Double.valueOf(columns[6])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setAbsolutePressure(Double.valueOf(columns[7])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setWind(Double.valueOf(columns[8])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setGust(Double.valueOf(columns[9])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setDirection(columns[10]); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setRelativePressure(Double.valueOf(columns[11])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setDewpoint(Double.valueOf(columns[12])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setWindChill(Double.valueOf(columns[13])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setHourRainfall(Double.valueOf(columns[14])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setDayRainfall(Double.valueOf(columns[15])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setWeekRainfall(Double.valueOf(columns[16])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setMonthRainfall(Double.valueOf(columns[17])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setTotalRainfall(Double.valueOf(columns[18])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setWindLevel(Double.valueOf(columns[19])); } catch (Exception e) { log.error("line " + lineCount, e); } try { meteoLog.setGustLevel(Double.valueOf(columns[20])); } catch (Exception e) { log.error("line " + lineCount, e); } ds.save(meteoLog, WriteConcern.NORMAL); lineCount++; } log.debug("Tot line insert:" + lineCount); log.debug("Tot line scarted:" + lineDouble); //move file to backup dir with rename final File toMove = new File( importPathBackup + "/" + f.getName() + "_" + System.currentTimeMillis()); log.debug("Move File to Backup dir" + toMove); f.renameTo(toMove); } } catch (IOException ex) { log.fatal(ex); } }
From source file:gov.usgs.cida.coastalhazards.rest.data.util.MetadataUtilTest.java
@After public void tearDown() { // FileUtils.listFiles(workDir, null, true).stream().forEach((file) -> { //FileUtils.deleteQuietly(file); //});// w w w . ja v a 2 s.c o m Collection<File> files = FileUtils.listFiles(workDir, null, true); for (File file : files) { FileUtils.deleteQuietly(file); } }
From source file:maven.plugin.javafmt.JavaFormatterMojo.java
@Override public void execute() throws MojoExecutionException, MojoFailureException { try {//from www. j a v a2s . c o m restoreStatus(); // CodeFormatter codeFormatter = getCodeFormatter(); // File srcDir = new File(basedir, "src"); Iterator<File> iter = FileUtils.listFiles(srcDir, new String[] { "java" }, true).iterator(); while (iter.hasNext()) { File javaFile = iter.next(); // if (shouldFormat(javaFile)) { // getLog().info("Format Java File : " + javaFile.getAbsolutePath()); // formatJavaFile(codeFormatter, javaFile); // updateStatus(javaFile); } } // storeStatus(); } catch (Exception e) { throw new MojoExecutionException("Java Code Format Exception!", e); } }
From source file:com.acmeair.reporter.parser.ResultParser.java
public void processDirectory(String dirName) { File root = new File(dirName); try {//from ww w . j av a2 s . c o m Collection<File> files = FileUtils.listFiles(root, new RegexFileFilter(getFileName()), DirectoryFileFilter.DIRECTORY); for (Iterator<File> iterator = files.iterator(); iterator.hasNext();) { File file = (File) iterator.next(); processFile(file); } } catch (Exception e) { e.printStackTrace(); } }