當前位置: 首頁>>代碼示例>>Java>>正文


Java FileFilterUtils.or方法代碼示例

本文整理匯總了Java中org.apache.commons.io.filefilter.FileFilterUtils.or方法的典型用法代碼示例。如果您正苦於以下問題:Java FileFilterUtils.or方法的具體用法?Java FileFilterUtils.or怎麽用?Java FileFilterUtils.or使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.io.filefilter.FileFilterUtils的用法示例。


在下文中一共展示了FileFilterUtils.or方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateConfigurationFiles

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
private void updateConfigurationFiles() throws EngineException {
	try {
		IOFileFilter fileFilter = FileFilterUtils.or(FileFilterUtils.suffixFileFilter("json"),FileFilterUtils.suffixFileFilter("xml"),FileFilterUtils.suffixFileFilter("js"));
		IOFileFilter dirFilter = FileFilterUtils.or(FileFilterUtils.nameFileFilter("config"));
		for (File f: FileUtils.listFiles(ionicWorkDir, fileFilter, dirFilter)) {
			String content = FileUtils.readFileToString(f, "UTF-8");
			content = content.replaceAll("../DisplayObjects","../../DisplayObjects");
			content = content.replaceAll("../Flashupdate","../../Flashupdate");
			writeFile(f, content, "UTF-8");
		}
		Engine.logEngine.debug("(MobileBuilder) Configuration files updated for ionic project '"+ project.getName() +"'");
	}
	catch (Exception e) {
		throw new EngineException("Unable to update configuration files for ionic project '"+ project.getName() +"'",e);
	}
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:17,代碼來源:MobileBuilder.java

示例2: check1

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
/**
 * 隻監控文件發送變化,如果是子目錄的文件改變,則目錄會變,由於沒有過濾目錄發生變化,則目錄下的文件改變不會監控到
 * @param dir
 * @throws Exception 
 */
public void check1(String dir) throws Exception
{
	File directory = new File(dir);
    // 輪詢間隔 5 秒
    long interval = TimeUnit.SECONDS.toMillis(5);
    // 創建一個文件觀察器用於處理文件的格式
    IOFileFilter filter=FileFilterUtils.or(FileFilterUtils.suffixFileFilter(".class"),
    		FileFilterUtils.suffixFileFilter(".jar"));
    FileAlterationObserver observer = new FileAlterationObserver(directory,filter);
    //設置文件變化監聽器
    observer.addListener(new MyFileListener());
    FileAlterationMonitor monitor = new FileAlterationMonitor(interval);
    monitor.addObserver(observer);//文件觀察
    monitor.start();
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:21,代碼來源:FileMonitor.java

示例3: check2

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
public void check2(String dir) throws Exception
	{
		File directory = new File(dir);
	    // 輪詢間隔 5 秒
	    long interval = TimeUnit.SECONDS.toMillis(5);
	    //後綴過濾器
	    IOFileFilter filefilter=FileFilterUtils.or(FileFilterUtils.suffixFileFilter(".class"),
	    		FileFilterUtils.suffixFileFilter(".jar"));
	    //子目錄的後綴
	    IOFileFilter subFilefilter=FileFilterUtils.or(FileFilterUtils.directoryFileFilter(),filefilter);
	    //根目錄和子目錄變化
	    IOFileFilter filter = FileFilterUtils.or(filefilter,subFilefilter);
	    FileAlterationObserver observer = new FileAlterationObserver(directory,filter);
	    //設置文件變化監聽器
	    observer.addListener(new MyFileListener());
	    FileAlterationMonitor monitor = new FileAlterationMonitor(interval);
	    monitor.addObserver(observer);//文件觀察
	    monitor.start();
//	    monitor.addObserver(observer);//文件觀察,如果在start後麵加,則會觸發所有文件創建
	}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:21,代碼來源:FileMonitor.java

示例4: buildFilterBySuffixs

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
protected IOFileFilter buildFilterBySuffixs(String directory,String ...suffixs)
{
    IOFileFilter iOFileFilter=FileFilterUtils.directoryFileFilter(); //子目錄變化
	for(String suffix:suffixs)
	{//後綴過濾器
		iOFileFilter=FileFilterUtils.or(iOFileFilter,FileFilterUtils.suffixFileFilter(suffix));
	}
    return iOFileFilter;
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:10,代碼來源:DefaultClassSource.java

示例5: buildFilterByNames

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
protected IOFileFilter buildFilterByNames(String directory,String ...fileName)
{
    IOFileFilter iOFileFilter=FileFilterUtils.directoryFileFilter(); //子目錄變化
	for(String name:fileName)
	{//名字過濾器
		iOFileFilter=FileFilterUtils.or(iOFileFilter,FileFilterUtils.nameFileFilter(name));
	}
    return iOFileFilter;
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:10,代碼來源:DefaultClassSource.java

示例6: buildFileAlterationObserver

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
protected FileAlterationObserver buildFileAlterationObserver(String directory)
{
    //後綴過濾器
    IOFileFilter suffixFileFilter=FileFilterUtils.or(FileFilterUtils.suffixFileFilter(".class"),FileFilterUtils.suffixFileFilter(".jar"));
    //子目錄變化
    IOFileFilter rootAndSubFilefilter=FileFilterUtils.or(FileFilterUtils.directoryFileFilter(),suffixFileFilter);
    return new FileAlterationObserver(directory,rootAndSubFilefilter);
}
 
開發者ID:juebanlin,項目名稱:util4j,代碼行數:9,代碼來源:DefaultScriptSource.java

示例7: Get

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
/**
 * Builds a *VisibleFilesTraverser*.
 * @param startDirectory
 * @param ignoreFileNames
 * @return
 */
public static VisibleFilesTraverser Get(Path startDirectory, String...ignoreFileNames) {
    return new VisibleFilesTraverser(
            startDirectory,
            ignoreFileNames,
            FileFilterUtils.or(
                    // Show visible directories
                    FileFilterUtils.and(FileFilterUtils.directoryFileFilter(), HiddenFileFilter.VISIBLE),
                    // Show visible files
                    FileFilterUtils.and(FileFilterUtils.fileFileFilter(), HiddenFileFilter.VISIBLE)
            )
    );
}
 
開發者ID:AMOSTeam3,項目名稱:amos-ss15-proj3,代碼行數:19,代碼來源:VisibleFilesTraverser.java

示例8: processJreArchives

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
/**
 * Process the JRE archives (recognized JAR files are: rt.jar, jsse.jar,
 * jce.jar).
 * 
 * @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));
}
 
開發者ID:karimhamdanali,項目名稱:averroes,代碼行數:16,代碼來源:JarOrganizer.java

示例9: TemplateWatcher

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
/**
 * Constructor.
 * @param manager the templating manager, to which event handling is delegated.
 * @param templateDir the templates directory to watch.
 * @param pollInterval the poll interval.
 * @throws IOException if there is a problem watching the template directory.
 */
public TemplateWatcher( final TemplatingManager manager, final File templateDir, final long pollInterval ) {
	this.templateDir = templateDir;

	// Register the custom helpers.
	this.handlebars.registerHelper( AllHelper.NAME, new AllHelper());
	this.handlebars.registerHelper( IsKeyHelper.NAME, new IsKeyHelper());

	// Pretty formatting
	this.handlebars.prettyPrint( true );

	// Create the observer, register this object as the event listener.
	FileFilter fileFilter = FileFilterUtils.or(
			FileFilterUtils.and(
					FileFilterUtils.fileFileFilter(),
					FileFilterUtils.suffixFileFilter( ".tpl" ),
					CanReadFileFilter.CAN_READ,
					new TemplateFileFilter(templateDir)),
			FileFilterUtils.and(
					FileFilterUtils.directoryFileFilter(),
					CanReadFileFilter.CAN_READ,
					new TemplateSubDirectoryFileFilter(templateDir))
	);

	FileAlterationObserver observer = new FileAlterationObserver( this.templateDir, fileFilter );
	observer.addListener( this );

	// Create the monitor.
	this.monitor = new FileAlterationMonitor( pollInterval, observer );
	this.monitor.setThreadFactory( THREAD_FACTORY );

	this.manager = manager;
	this.logger.fine( "Template watcher is watching "
			+ this.templateDir
			+ " with an interval of " + pollInterval + " ms." );
}
 
開發者ID:roboconf,項目名稱:roboconf-platform,代碼行數:43,代碼來源:TemplateWatcher.java

示例10: 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);
}
 
開發者ID:semperos,項目名稱:screwdriver,代碼行數:18,代碼來源:FileUtil.java

示例11: fileFilterForExtensions

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
public static IOFileFilter fileFilterForExtensions(List<String> extensions) {
        IOFileFilter[] fileFilters = new IOFileFilter[extensions.size()];
        for (int i = 0; i < extensions.size(); i++) {
            fileFilters[i] = fileFilterForExtension(extensions.get(i));
        }
//        IOFileFilter directories = defaultDirectoryFilter();
//        IOFileFilter files = FileFilterUtils.or(fileFilters);
        return FileFilterUtils.or(fileFilters);
    }
 
開發者ID:semperos,項目名稱:screwdriver,代碼行數:10,代碼來源:FileUtil.java

示例12: DirectoryWalker

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
/**
 * Construct an instance with a directory and a file filter and an optional
 * limit on the <i>depth</i> navigated to.
 * <p>
 * The filters control which files and directories will be navigated to as part
 * of the walk. This constructor uses {@link FileFilterUtils#makeDirectoryOnly(IOFileFilter)}
 * and {@link FileFilterUtils#makeFileOnly(IOFileFilter)} internally to combine the filters.
 * A <code>null</code> filter means that no filtering should occur.
 *
 * @param directoryFilter  the filter to apply to directories, null means visit all directories
 * @param fileFilter  the filter to apply to files, null means visit all files
 * @param depthLimit  controls how <i>deep</i> the hierarchy is
 *  navigated to (less than 0 means unlimited)
 */
protected DirectoryWalker(IOFileFilter directoryFilter, IOFileFilter fileFilter, int depthLimit) {
    if (directoryFilter == null && fileFilter == null) {
        this.filter = null;
    } else {
        directoryFilter = (directoryFilter != null ? directoryFilter : TrueFileFilter.TRUE);
        fileFilter = (fileFilter != null ? fileFilter : TrueFileFilter.TRUE);
        directoryFilter = FileFilterUtils.makeDirectoryOnly(directoryFilter);
        fileFilter = FileFilterUtils.makeFileOnly(fileFilter);
        this.filter = FileFilterUtils.or(directoryFilter, fileFilter);
    }
    this.depthLimit = depthLimit;
}
 
開發者ID:fesch,項目名稱:Moenagade,代碼行數:27,代碼來源:DirectoryWalker.java

示例13: DirectoryWalker

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
/**
 * Construct an instance with a directory and a file filter and an optional
 * limit on the <i>depth</i> navigated to.
 * <p>
 * The filters control which files and directories will be navigated to as part
 * of the walk. This constructor uses {@link FileFilterUtils#makeDirectoryOnly(IOFileFilter)}
 * and {@link FileFilterUtils#makeFileOnly(IOFileFilter)} internally to combine the filters.
 * A {@code null} filter means that no filtering should occur.
 *
 * @param directoryFilter  the filter to apply to directories, null means visit all directories
 * @param fileFilter  the filter to apply to files, null means visit all files
 * @param depthLimit  controls how <i>deep</i> the hierarchy is
 *  navigated to (less than 0 means unlimited)
 */
protected DirectoryWalker(IOFileFilter directoryFilter, IOFileFilter fileFilter, int depthLimit) {
    if (directoryFilter == null && fileFilter == null) {
        this.filter = null;
    } else {
        directoryFilter = directoryFilter != null ? directoryFilter : TrueFileFilter.TRUE;
        fileFilter = fileFilter != null ? fileFilter : TrueFileFilter.TRUE;
        directoryFilter = FileFilterUtils.makeDirectoryOnly(directoryFilter);
        fileFilter = FileFilterUtils.makeFileOnly(fileFilter);
        this.filter = FileFilterUtils.or(directoryFilter, fileFilter);
    }
    this.depthLimit = depthLimit;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:DirectoryWalker.java

示例14: main

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
/**
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {


    // 監控根目錄,會遞歸監控子文件夾變化

    String rootDir = "D:\\download";
    // 輪詢間隔 5 秒,通過重新啟動 FileAlterationMonitor 實現
    long interval = TimeUnit.SECONDS.toMillis(5);


    // 創建一個文件觀察器用於處理文件的格式
    // Create a FileFilter
    IOFileFilter directories = FileFilterUtils.and(FileFilterUtils.directoryFileFilter(), HiddenFileFilter.VISIBLE);
    IOFileFilter files = FileFilterUtils.and(FileFilterUtils.fileFileFilter(), FileFilterUtils.suffixFileFilter(".java"));
    IOFileFilter filter = FileFilterUtils.or(directories, files);

    // Create the File system observer and register File Listeners
    FileAlterationObserver observer = new FileAlterationObserver(rootDir, filter, null);
    observer.addListener(new FileMonitorFileListener()); //設置文件變化監聽器

    //創建文件變化監聽器
    FileAlterationMonitor monitor = new FileAlterationMonitor(interval, observer);

    // 開始監控
    monitor.start();

}
 
開發者ID:h819,項目名稱:spring-boot,代碼行數:32,代碼來源:FileMonitorTest.java

示例15: DirectoryWalker

import org.apache.commons.io.filefilter.FileFilterUtils; //導入方法依賴的package包/類
/**
 * Construct an instance with a directory and a file filter and an optional
 * limit on the <i>depth</i> navigated to.
 * <p>
 * The filters control which files and directories will be navigated to as part
 * of the walk. This constructor uses {@link FileFilterUtils#makeDirectoryOnly(IOFileFilter)}
 * and {@link FileFilterUtils#makeFileOnly(IOFileFilter)} internally to combine the filters.
 * A {@code null} filter means that no filtering should occur.
 *
 * @param directoryFilter  the filter to apply to directories, null means visit all directories
 * @param fileFilter  the filter to apply to files, null means visit all files
 * @param depthLimit  controls how <i>deep</i> the hierarchy is
 *  navigated to (less than 0 means unlimited)
 */
protected DirectoryWalker(IOFileFilter directoryFilter, IOFileFilter fileFilter, final int depthLimit) {
    if (directoryFilter == null && fileFilter == null) {
        this.filter = null;
    } else {
        directoryFilter = directoryFilter != null ? directoryFilter : TrueFileFilter.TRUE;
        fileFilter = fileFilter != null ? fileFilter : TrueFileFilter.TRUE;
        directoryFilter = FileFilterUtils.makeDirectoryOnly(directoryFilter);
        fileFilter = FileFilterUtils.makeFileOnly(fileFilter);
        this.filter = FileFilterUtils.or(directoryFilter, fileFilter);
    }
    this.depthLimit = depthLimit;
}
 
開發者ID:PuppyRush,項目名稱:WidgetStore,代碼行數:27,代碼來源:DirectoryWalker.java


注:本文中的org.apache.commons.io.filefilter.FileFilterUtils.or方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。