List of usage examples for org.apache.commons.io.filefilter FalseFileFilter INSTANCE
IOFileFilter INSTANCE
To view the source code for org.apache.commons.io.filefilter FalseFileFilter INSTANCE.
Click Source Link
From source file:com.nuvolect.deepdive.util.OmniFileFilter.java
/** * Finds files within a given directory (and optionally its subdirectories) * which match an array of extensions./*from ww w.j av a 2 s. com*/ * * @param directory the directory to search in * @param extensions an array of extensions, ex. {"java","xml"}. If this * parameter is {@code null}, all files are returned. * @param recursive if true all subdirectories are searched as well * @return an collection of java.io.File with the matching files */ public static Collection<OmniFile> listFiles(final OmniFile directory, final String[] extensions, final boolean recursive) { IOFileFilter filter; if (extensions == null) { filter = TrueFileFilter.INSTANCE; } else { final String[] suffixes = toSuffixes(extensions); filter = new SuffixFileFilter(suffixes); } return listFiles(directory, filter, recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE); }
From source file:channellistmaker.listmaker.fileseeker.FileSeeker.java
/** * ??true???????true//from w ww .j av a 2 s . co m * * @param recursive */ public synchronized void setRecursive(boolean recursive) { if (recursive == false) { this.dirf = FalseFileFilter.INSTANCE; } else { this.dirf = TrueFileFilter.INSTANCE; } }
From source file:com.xebialabs.deployit.cli.ext.mustachify.io.Files2.java
/** * A variation on {@link FileUtils#listFiles(File, IOFileFilter, IOFileFilter) listFiles} * that also optionally includes directories matched in the result. *///from ww w . j av a2 s . c om public static Collection<File> listFiles(File directory, IOFileFilter fileFilter, IOFileFilter dirFilter, boolean includeDirs) { if (!directory.isDirectory()) { throw new IllegalArgumentException("Parameter 'directory' is not a directory"); } if (fileFilter == null) { throw new NullPointerException("Parameter 'fileFilter' is null"); } //Setup effective file filter IOFileFilter effFileFilter = FileFilterUtils.andFileFilter(fileFilter, FileFilterUtils.notFileFilter(DirectoryFileFilter.INSTANCE)); //Setup effective directory filter IOFileFilter effDirFilter; if (dirFilter == null) { effDirFilter = FalseFileFilter.INSTANCE; } else { effDirFilter = FileFilterUtils.andFileFilter(dirFilter, DirectoryFileFilter.INSTANCE); } //Find files Collection<File> files = new LinkedList<File>(); innerListFiles(files, directory, FileFilterUtils.orFileFilter(effFileFilter, effDirFilter), includeDirs); return files; }
From source file:ext.deployit.community.cli.plainarchive.io.Files2.java
/** * A variation on {@link FileUtils#listFiles(File, IOFileFilter, IOFileFilter) listFiles} * that also optionally includes directories matched in the result. *//* ww w. jav a 2 s .c om*/ public static Collection<File> listFiles(File directory, IOFileFilter fileFilter, IOFileFilter dirFilter, boolean includeDirs) { if (!directory.isDirectory()) { throw new IllegalArgumentException(format("Parameter '%s' is not a directory", directory)); } if (fileFilter == null) { throw new NullPointerException("Parameter 'fileFilter' is null"); } //Setup effective file filter IOFileFilter effFileFilter = FileFilterUtils.andFileFilter(fileFilter, FileFilterUtils.notFileFilter(DirectoryFileFilter.INSTANCE)); //Setup effective directory filter IOFileFilter effDirFilter; if (dirFilter == null) { effDirFilter = FalseFileFilter.INSTANCE; } else { effDirFilter = FileFilterUtils.andFileFilter(dirFilter, DirectoryFileFilter.INSTANCE); } //Find files Collection<File> files = new LinkedList<File>(); innerListFiles(files, directory, FileFilterUtils.orFileFilter(effFileFilter, effDirFilter), includeDirs); return files; }
From source file:com.epam.wilma.common.helper.FileUtils.java
/** * Collects the file names in the target folder with the given filter in non recursive way. * @param folder is the target folder/*from w w w . j a v a2 s. c om*/ * @param filter is the regular expression of filtering logic * @return with the file names */ public Collection<File> listFilesWithFilter(final File folder, final String filter) { Collection<File> result; try { result = org.apache.commons.io.FileUtils.listFiles(folder, new RegexFileFilter(filter), FalseFileFilter.INSTANCE); } catch (IllegalArgumentException e) { result = logAndReturnEmptyList(folder, e); } return result; }
From source file:com.thoughtworks.go.server.GoServer.java
private List<File> getAddonJarFiles() { File addonsPath = new File(systemEnvironment.get(SystemEnvironment.ADDONS_PATH)); if (!addonsPath.exists() || !addonsPath.canRead()) { return new ArrayList<>(); }//from w ww. j ava 2 s . c om return new ArrayList<>(FileUtils.listFiles(addonsPath, new SuffixFileFilter("jar", IOCase.INSENSITIVE), FalseFileFilter.INSTANCE)); }
From source file:com.thoughtworks.go.agent.bootstrapper.AgentBootstrapper.java
private void cleanupTempFiles() { FileUtils.deleteQuietly(new File(FileUtil.TMP_PARENT_DIR)); FileUtils.deleteQuietly(new File("exploded_agent_launcher_dependencies")); // launchers extracted from old versions FileUtils.listFiles(new File("."), AGENT_LAUNCHER_TMP_FILE_FILTER, FalseFileFilter.INSTANCE) .forEach(FileUtils::deleteQuietly); FileUtils.deleteQuietly(new File(new SystemEnvironment().getConfigDir(), "trust.jks")); }
From source file:com.nuvolect.deepdive.util.OmniFileFilter.java
/** * Returns a filter that accepts directories in addition to the {@link OmniFile} objects accepted by the given filter. * * @param dirFilter a base filter to add to * @return a filter that accepts directories *//*from w w w .j a va 2 s. co m*/ private static IOFileFilter setUpEffectiveDirFilter(final IOFileFilter dirFilter) { return dirFilter == null ? FalseFileFilter.INSTANCE : FileFilterUtils.and(dirFilter, DirectoryFileFilter.INSTANCE); }
From source file:com.infosupport.ellison.core.archive.ApplicationArchive.java
/** * Finds all files in a directory matching a specific pattern. * <p/>/*w w w .jav a2 s .c om*/ * For a definition of what kinds of patterns are supported, see {@link WildcardFileFilter}. * * @param basePath * the name of the base directory to search in. May be null if looking for files from the root directory. * @param wildcardPattern * files matching this pattern will be in the returned collection. See {@link WildcardFileFilter} for the * pattern format * @param doRecursively * whether to search for files matching {@code wildcardPattern} recursively or not. * * @return a list of all files matching {@code wildcardPattern} in directory {@code basePath} within this * application archive. * * @throws FileNotFoundException * if {@code basePath != null} and {@code basePath} does not point to an existing file in the application * archive */ public Collection<URI> findFilesByGlobPattern(String basePath, String wildcardPattern, boolean doRecursively) throws FileNotFoundException { IOFileFilter fileFilter = new WildcardFileFilter(wildcardPattern); File baseDir = null; IOFileFilter dirFilter = null; if (basePath == null) { baseDir = unpackedPath; } else { if (!isPathRelative(basePath)) { throw new SecurityException( "It is not permitted to supply base paths containing references to parent directories ('..')."); } baseDir = new File(unpackedPath, basePath); } if (doRecursively) { dirFilter = TrueFileFilter.INSTANCE; } else { dirFilter = FalseFileFilter.INSTANCE; } if (!baseDir.exists()) { throw new FileNotFoundException(String.format("Basepath '%s' does not exist within archive '%s'", basePath, getApplicationFile().getAbsolutePath())); } if (!baseDir.isDirectory()) { throw new IllegalArgumentException( String.format("Basepath '%s' is not a directory within the archive", basePath)); } return Collections2.transform(FileUtils.listFiles(baseDir, fileFilter, dirFilter), new Function<File, URI>() { @Override public URI apply(File input) { return relativizePath(input.toURI()); } }); }
From source file:com.sangupta.jerry.util.FileUtils.java
/** * List the files in the given path string with wild cards. * //from w w w .j a v a2 s . c o m * @param baseDir * the base directory to search for files in * * @param filePathWithWildCards * the file path to search in - can be absolute * * @param recursive * whether to look in sub-directories or not * * @param additionalFilters * additional file filters that need to be used when scanning for * files * * @return the list of files and directories that match the criteria */ public static List<File> listFiles(File baseDir, String filePathWithWildCards, boolean recursive, List<IOFileFilter> additionalFilters) { if (filePathWithWildCards == null) { throw new IllegalArgumentException("Filepath cannot be null"); } // change *.* to * filePathWithWildCards = filePathWithWildCards.replace("*.*", "*"); // normalize filePathWithWildCards = FilenameUtils.normalize(filePathWithWildCards); if (filePathWithWildCards.endsWith(File.pathSeparator)) { filePathWithWildCards += "*"; } // check if this is an absolute path or not String prefix = FilenameUtils.getPrefix(filePathWithWildCards); final boolean isAbsolute = !prefix.isEmpty(); // change the base dir if absolute directory if (isAbsolute) { baseDir = new File(filePathWithWildCards); if (!baseDir.isDirectory()) { // not a directory - get the base directory filePathWithWildCards = baseDir.getName(); if (filePathWithWildCards.equals("~")) { filePathWithWildCards = "*"; } if (AssertUtils.isEmpty(filePathWithWildCards)) { filePathWithWildCards = "*"; } baseDir = baseDir.getParentFile(); if (baseDir == null) { baseDir = getUsersHomeDirectory(); } } } // check if the provided argument is a directory File dir = new File(filePathWithWildCards); if (dir.isDirectory()) { baseDir = dir.getAbsoluteFile(); filePathWithWildCards = "*"; } else { // let's check for base directory File parent = dir.getParentFile(); if (parent != null) { baseDir = parent.getAbsoluteFile(); filePathWithWildCards = dir.getName(); } } // check for user home String basePath = baseDir.getPath(); if (basePath.startsWith("~")) { basePath = getUsersHomeDirectory().getAbsolutePath() + File.separator + basePath.substring(1); basePath = FilenameUtils.normalize(basePath); baseDir = new File(basePath); } // now read the files WildcardFileFilter wildcardFileFilter = new WildcardFileFilter(filePathWithWildCards, IOCase.SYSTEM); IOFileFilter finalFilter = wildcardFileFilter; if (AssertUtils.isNotEmpty(additionalFilters)) { additionalFilters.add(0, wildcardFileFilter); finalFilter = new AndFileFilter(additionalFilters); } Collection<File> files = org.apache.commons.io.FileUtils.listFiles(baseDir, finalFilter, recursive ? TrueFileFilter.INSTANCE : FalseFileFilter.INSTANCE); return (List<File>) files; }