List of usage examples for org.apache.commons.io.filefilter FileFilterUtils nameFileFilter
public static IOFileFilter nameFileFilter(String name)
From source file:com.partnet.automation.util.PathUtils.java
/** * Search for a specific file nested inside of a specific path * //from w w w . j ava 2 s . c om * @param path * - path that contains the file * @param fileName * - file name of the file * @return - the file that was found * * @throws IllegalStateException * - if more then one file with that specific name was found. */ public static File getFileInPath(final String path, final String fileName) { File dir = new File(path); // find the correct file List<File> files = (List<File>) FileUtils.listFiles(dir, FileFilterUtils.nameFileFilter(fileName), TrueFileFilter.TRUE); LOG.debug("Files found: {}", Arrays.asList(files)); if (files.size() != 1) { throw new IllegalStateException(String.format( "Searching for a file '%s' did not result in the correct number of files! Found %d, expected %d", fileName, files.size(), 1)); } return files.get(0); }
From source file:ch.ivyteam.ivy.maven.engine.deploy.FileLogForwarder.java
public synchronized void activate() throws MojoExecutionException { IOFileFilter logFilter = FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.nameFileFilter(engineLog.getName())); FileAlterationObserver fileObserver = new FileAlterationObserver(engineLog.getParent(), logFilter); fileObserver.addListener(new LogModificationListener()); monitor = new FileAlterationMonitor(100); monitor.addObserver(fileObserver);// w w w .ja v a 2s. co m try { monitor.start(); } catch (Exception ex) { throw new MojoExecutionException("Failed to activate deploy log forwarder", ex); } }
From source file:com.ning.metrics.collector.hadoop.processing.LocalSpoolManager.java
public static Collection<File> findFilesInSpoolDirectory(final File spoolDirectory) { if (!spoolDirectory.isDirectory()) { log.warn("Asked to find files in spool directory but [" + spoolDirectory + "] is not a directory!"); return Collections.emptyList(); }/* www . ja v a 2 s . c o m*/ return FileUtils.listFiles(spoolDirectory, FileFilterUtils.trueFileFilter(), FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("_tmp"))); }
From source file:com.aionengine.gameserver.dataholders.DataLoader.java
/** * This method is supposed to be called from subclass to initialize data loading process.<br> * <br>/*from w ww . j a va2 s .c o m*/ * This method is using file given in the constructor to load the data and there are two possibilities: * <ul> * <li>Given file is file is in deed the <b>file</b> then it's forwarded to {@link #loadFile(File)} method</li> * <li>Given file is a <b>directory</b>, then this method is obtaining list of all visible .txt files in this * directory and subdirectiores ( except hidden ones and those named "new" ) and call {@link #loadFile(File)} for * each of these files. * </ul> */ protected void loadData() { if (dataFile.isDirectory()) { Collection<?> files = FileUtils .listFiles(dataFile, FileFilterUtils .andFileFilter( FileFilterUtils.andFileFilter( FileFilterUtils .notFileFilter(FileFilterUtils.nameFileFilter("new")), FileFilterUtils.suffixFileFilter(".txt")), HiddenFileFilter.VISIBLE), HiddenFileFilter.VISIBLE); for (Object file1 : files) { File f = (File) file1; loadFile(f); } } else { loadFile(dataFile); } }
From source file:com.aionemu.gameserver.dataholders.DataLoader.java
/** * This method is supposed to be called from subclass to initialize data * loading process.<br>/*from w w w. j a v a2 s . co m*/ * <br> * This method is using file given in the constructor to load the data and * there are two possibilities: * <ul> * <li>Given file is file is in deed the <b>file</b> then it's forwarded to * {@link #loadFile(File)} method</li> * <li>Given file is a <b>directory</b>, then this method is obtaining list * of all visible .txt files in this directory and subdirectiores ( except * hidden ones and those named "new" ) and call {@link #loadFile(File)} for * each of these files. * </ul> */ @SuppressWarnings("deprecation") protected void loadData() { if (dataFile.isDirectory()) { Collection<?> files = FileUtils .listFiles(dataFile, FileFilterUtils .andFileFilter( FileFilterUtils.andFileFilter( FileFilterUtils .notFileFilter(FileFilterUtils.nameFileFilter("new")), FileFilterUtils.suffixFileFilter(".txt")), HiddenFileFilter.VISIBLE), HiddenFileFilter.VISIBLE); for (Object file1 : files) { File f = (File) file1; loadFile(f); } } else { loadFile(dataFile); } }
From source file:com.tactfactory.harmony.Harmony.java
/** * @param pluginBaseDirectory The plugin base directory *///from w w w . java2 s.c o m private void loadPluginsAndTemplate(final File pluginBaseDirectory) { // Cache final JSPFProperties props = new JSPFProperties(); /*props.setProperty(PluginManager.class, "cache.enabled", "true"); // Optional props.setProperty(PluginManager.class, "cache.mode", "weak"); props.setProperty(PluginManager.class, "cache.file", "jspf.cache");*/ // Filters final IOFileFilter includeFilter = FileFilterUtils.suffixFileFilter(".jar"); final IOFileFilter excludeFilter = FileFilterUtils.and( FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("lib")), FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("libs"))); // Check list of Bundles .jar final Collection<File> plugins = TactFileUtils.listFiles(pluginBaseDirectory, includeFilter, excludeFilter); // Add Bundles to Plugin Manager & foldertemplate for (File plugin : plugins) { this.loadPlugin(plugin, props); this.loadTemplates(plugin); } }
From source file:averroes.JarOrganizer.java
/** * Process the JRE archives (recognized JAR files are: rt.jar, jsse.jar, * jce.jar).//from w w w. ja v a 2s .c o m * * @param dir */ private void processJreArchives(String dir) { File directory = new File(dir); org.apache.commons.io.filefilter.IOFileFilter nameFilter = FileFilterUtils.or( FileFilterUtils.nameFileFilter("rt.jar"), FileFilterUtils.nameFileFilter("jsse.jar"), FileFilterUtils.nameFileFilter("jce.jar")); FileUtils.listFiles(directory, nameFilter, FileFilterUtils.trueFileFilter()) .forEach(file -> processArchive(file.getPath(), false)); }
From source file:com.hj.blog.common.utils.SensitiveWordMonitor.java
public void monitor(String directory, int interval) { FileAlterationObserver fileAlterationObserver = new FileAlterationObserver(directory, FileFilterUtils.and(FileFilterUtils.nameFileFilter(SENSITIVE_WORD_FILE_NAME)), null); fileAlterationObserver.addListener(this); FileAlterationMonitor fileAlterationMonitor = new FileAlterationMonitor(interval, fileAlterationObserver); try {//from www . j a v a 2s. co m fileAlterationMonitor.start(); } catch (Exception e) { e.printStackTrace(); } }
From source file:fr.duminy.jbackup.core.archive.FileCollectorTest.java
@Test public void testCollect_file1() throws Exception { Path[] files = { expectedFiles[0] }; testCollect(files, trueFileFilter(), FileFilterUtils.nameFileFilter(FILE1), null); }
From source file:fr.duminy.jbackup.core.archive.FileCollectorTest.java
@Test public void testCollect_file2() throws Exception { Path[] files = { expectedFiles[1] }; testCollect(files, trueFileFilter(), FileFilterUtils.nameFileFilter(FILE2), null); }