本文整理汇总了Java中org.apache.commons.io.filefilter.FileFilterUtils.and方法的典型用法代码示例。如果您正苦于以下问题:Java FileFilterUtils.and方法的具体用法?Java FileFilterUtils.and怎么用?Java FileFilterUtils.and使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.filefilter.FileFilterUtils
的用法示例。
在下文中一共展示了FileFilterUtils.and方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findGitRepos
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
public static List<String> findGitRepos(String dirPath) {
File dir = new File(dirPath);
IOFileFilter gitDirFilter = (IOFileFilter) FileFilterUtils.suffixFileFilter(".git");
IOFileFilter notFile = FileFilterUtils.notFileFilter(TrueFileFilter.INSTANCE);
IOFileFilter compositeFilter = FileFilterUtils.and(notFile, gitDirFilter);
List<File> files = (List<File>) FileUtils.listFilesAndDirs(dir,compositeFilter,DirectoryFileFilter.INSTANCE);
List<String> results = new ArrayList<String>();
for(File f: files) {
try {
if(!f.getCanonicalPath().endsWith("/.git"))
continue;
String gitStripped = f.getCanonicalPath().replace("/.git", "");
System.out.println(gitStripped);
results.add(gitStripped);
} catch (IOException e) {
e.printStackTrace();
}
}
return results;
}
示例2: activate
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
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);
try
{
monitor.start();
}
catch (Exception ex)
{
throw new MojoExecutionException("Failed to activate deploy log forwarder", ex);
}
}
示例3: fileFilter
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
private IOFileFilter fileFilter() {
IOFileFilter fileFileFilter = FileFilterUtils.fileFileFilter();
IOFileFilter[] noes = new IOFileFilter[]{
new RegexFileFilter(B + X + D + "class" + E),
new RegexFileFilter(B + X + D + "db" + E),
new RegexFileFilter(B + X + D + "ear" + E),
new RegexFileFilter(B + X + D + "err" + E),
new RegexFileFilter(B + X + D + "gif" + E),
new RegexFileFilter(B + X + D + "jar" + E),
new RegexFileFilter(B + X + D + "jpg" + E),
new RegexFileFilter(B + X + D + "lnk" + E),
new RegexFileFilter(B + X + D + "log" + E),
new RegexFileFilter(B + X + D + "nbm" + E),
new RegexFileFilter(B + X + D + "out" + E),
new RegexFileFilter(B + X + D + "png" + E),
new RegexFileFilter(B + X + D + "war" + E),
new RegexFileFilter(B + X + D + "zip" + E)
};
IOFileFilter noesFileFilter = FileFilterUtils.notFileFilter(FileFilterUtils.or(noes));
IOFileFilter filter = FileFilterUtils.and(fileFileFilter, noesFileFilter);
return filter;
}
示例4: listFiles
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
/**
* Finds files within a given directory (and optionally its
* subdirectories). All files found are filtered by an IOFileFilter.
* <p>
* If your search should recurse into subdirectories you can pass in
* an IOFileFilter for directories. You don't need to bind a
* DirectoryFileFilter (via logical AND) to this filter. This method does
* that for you.
* <p>
* An example: If you want to search through all directories called
* "temp" you pass in <code>FileFilterUtils.NameFileFilter("temp")</code>
* <p>
* Another common usage of this method is find files in a directory
* tree but ignoring the directories generated CVS. You can simply pass
* in <code>FileFilterUtils.makeCVSAware(null)</code>.
*
* @param directory the directory to search in
* @param fileFilter filter to apply when finding files.
* @param dirFilter optional filter to apply when finding subdirectories.
* If this parameter is <code>null</code>, subdirectories will not be included in the
* search. Use TrueFileFilter.INSTANCE to match all directories.
* @return an collection of java.io.File with the matching files
* @see org.apache.commons.io.filefilter.FileFilterUtils
* @see org.apache.commons.io.filefilter.NameFileFilter
*/
public static Collection<File> listFiles(
File directory, IOFileFilter fileFilter, IOFileFilter dirFilter) {
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.and(fileFilter,
FileFilterUtils.notFileFilter(DirectoryFileFilter.INSTANCE));
//Setup effective directory filter
IOFileFilter effDirFilter;
if (dirFilter == null) {
effDirFilter = FalseFileFilter.INSTANCE;
} else {
effDirFilter = FileFilterUtils.and(dirFilter,
DirectoryFileFilter.INSTANCE);
}
//Find files
Collection<File> files = new java.util.LinkedList<File>();
innerListFiles(files, directory,
FileFilterUtils.or(effFileFilter, effDirFilter));
return files;
}
示例5: monitor
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
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 {
fileAlterationMonitor.start();
} catch (Exception e) {
e.printStackTrace();
}
}
示例6: prepareLayoutFiles
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
/**
* This method is responsible to copy layout folder to destination directory and not copy template .html files
* @param outputDir
* @throws IOException
*/
private void prepareLayoutFiles(File outputDir) throws IOException {
URL url = getClass().getResource("/layout");
IOFileFilter notHtmlFilter = FileFilterUtils.notFileFilter(FileFilterUtils.suffixFileFilter(".html"));
FileFilter filter = FileFilterUtils.and(notHtmlFilter);
//cleanDirectory(outputDir,"/diagrams");
//cleanDirectory(outputDir,"/tables");
ResourceWriter.copyResources(url, outputDir, filter);
}
示例7: dirFilter
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
private IOFileFilter dirFilter() {
IOFileFilter makeFileFilter = FileFilterUtils.makeCVSAware(FileFilterUtils.makeSVNAware(null));
IOFileFilter metaFileFilter = new RegexPathFilter(B + X + S + "velocity" + S + "templates" + S + "meta" + S + X + E);
IOFileFilter mesaFileFilter = FileFilterUtils.notFileFilter(metaFileFilter);
IOFileFilter[] noes = new IOFileFilter[]{
new RegexFileFilter(B + "build" + E),
new RegexFileFilter(B + "dist" + E),
new RegexFileFilter(B + "private" + E),
new RegexFileFilter(B + "test" + E)
};
IOFileFilter noesFileFilter = FileFilterUtils.notFileFilter(FileFilterUtils.or(noes));
IOFileFilter filter = FileFilterUtils.and(makeFileFilter, mesaFileFilter, noesFileFilter);
return filter;
}
示例8: dirFilter
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
private IOFileFilter dirFilter() {
IOFileFilter makeCVSSVNAware = FileFilterUtils.makeCVSAware(FileFilterUtils.makeSVNAware(null));
IOFileFilter[] noes = new IOFileFilter[]{
new RegexFileFilter(B + X + D + "git" + E),
new RegexFileFilter(B + "build" + E),
new RegexFileFilter(B + "dist" + E),
new RegexFileFilter(B + "target" + E)
};
IOFileFilter noesFileFilter = FileFilterUtils.notFileFilter(FileFilterUtils.or(noes));
IOFileFilter filter = FileFilterUtils.and(makeCVSSVNAware, noesFileFilter);
return filter;
}
示例9: testParameterDefinitions
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
public static void testParameterDefinitions(String outputDirectory, String... excludeFiles)
throws ClassNotFoundException {
IOFileFilter includeFilter = new SuffixFileFilter(".java");
if (excludeFiles != null) {
IOFileFilter excludeFilter = FileFilterUtils.notFileFilter(new SuffixFileFilter(excludeFiles));
includeFilter = FileFilterUtils.and(excludeFilter, includeFilter);
}
Iterator<File> files = org.apache.commons.io.FileUtils.iterateFiles(
new File(outputDirectory),
includeFilter,
TrueFileFilter.INSTANCE);
testParameterDefinitions(files);
}
示例10: findTranscripts
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
protected Collection<File> findTranscripts(File dir, String filePattern) {
IOFileFilter fileFilter = FileFilterUtils.suffixFileFilter(TRANSCRIPT_EXTENSION);
if (StringUtils.isNotBlank(filePattern)) {
fileFilter = FileFilterUtils.and(
fileFilter,
FileFilterUtils.nameFileFilter(filePattern));
}
//Get all XML files, no recursion
return FileUtils.listFiles(dir, fileFilter, null);
}
示例11: extractPossibleDataFile
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
private static List<File> extractPossibleDataFile(File dwcFolder) {
List<File> dataFiles = new ArrayList<>();
for (String suffix : DATA_FILE_SUFFICES) {
FileFilter ff = FileFilterUtils.and(
FileFilterUtils.suffixFileFilter(suffix, IOCase.INSENSITIVE), HiddenFileFilter.VISIBLE
);
dataFiles.addAll(Arrays.asList(dwcFolder.listFiles(ff)));
}
return dataFiles;
}
示例12: getModsFileFilter
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
/**
* Creates a filter that returns everything in the "mods" folder except
* the specified cubes which are distributed with each new release and
* any existing themes which are now found in the "themes" folder.
*/
private FileFilter getModsFileFilter() {
final String[] excludedCubes = new String[]{
"legacy_cube.txt", "modern_cube.txt", "standard_cube.txt", "extended_cube.txt", "ubeefx_cube.txt"
};
final IOFileFilter cubesFilter = new NameFileFilter(excludedCubes, IOCase.INSENSITIVE);
final IOFileFilter excludeCubes = FileFilterUtils.notFileFilter(cubesFilter);
final IOFileFilter excludeThemes = FileFilterUtils.notFileFilter(new WildcardFileFilter("*_theme*"));
return FileFilterUtils.and(excludeCubes, excludeThemes);
}
示例13: getFolders
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
public List<String> getFolders()
throws MojoExecutionException
{
IOFileFilter folders = FileFilterUtils.and( HiddenFileFilter.VISIBLE, DirectoryFileFilter.DIRECTORY );
IOFileFilter makeSVNAware = FileFilterUtils.makeSVNAware( folders );
IOFileFilter makeCVSAware = FileFilterUtils.makeCVSAware( makeSVNAware );
String[] list = folder.list( makeCVSAware );
if ( list == null )
{
throw new MojoExecutionException( "The specified folder doesn't exist: " + folder );
}
List<File> listOfDirectories = new ArrayList<File>();
for ( String item : list )
{
listOfDirectories.add( new File( folder, item ) );
}
Collections.sort( listOfDirectories, convertSortOrder() );
List<String> resultList = new ArrayList<String>();
for ( File file : listOfDirectories )
{
resultList.add( file.getName() );
}
return resultList;
}
示例14: fileFilterForExtension
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
/**
* Setup an {@link IOFileFilter} that navigates recursively through
* directories, returning files that match {@code extension}
*
* @param extension The extension (leading "." optional) to filter for
* @return An instance of {@link IOFileFilter} to be used for a file system observer
*/
public static IOFileFilter fileFilterForExtension(String extension) {
if (!extension.startsWith(".")) {
extension = "." + extension;
}
IOFileFilter directories = defaultDirectoryFilter();
IOFileFilter files = FileFilterUtils.and(
FileFilterUtils.fileFileFilter(),
FileFilterUtils.suffixFileFilter(extension));
return FileFilterUtils.or(directories, files);
}
示例15: testFileFilterExclusions
import org.apache.commons.io.filefilter.FileFilterUtils; //导入方法依赖的package包/类
@Test
public void testFileFilterExclusions() throws Exception {
// exclude directories named "bootstrap"
IOFileFilter dirFilter = FileFilterUtils.and(
FileFilterUtils.notFileFilter(new NameFileFilter("bootstrap")),
DirectoryFileFilter.DIRECTORY);
cfg.setCssDirFilter(dirFilter);
BuildAll.build(cfg);
Collection<File> files = TestUtil.cssOutputFiles();
assertEquals(2, files.size());
}