当前位置: 首页>>代码示例>>Java>>正文


Java FileFilterUtils类代码示例

本文整理汇总了Java中org.apache.commons.io.filefilter.FileFilterUtils的典型用法代码示例。如果您正苦于以下问题:Java FileFilterUtils类的具体用法?Java FileFilterUtils怎么用?Java FileFilterUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileFilterUtils类属于org.apache.commons.io.filefilter包,在下文中一共展示了FileFilterUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResourcesWithExtension

import org.apache.commons.io.filefilter.FileFilterUtils; //导入依赖的package包/类
public ArrayList<String> getResourcesWithExtension(String ext, String containerName) {
	ArrayList<String> ret = new ArrayList<String>();
	if (containerName != null) {
		String[] names = StringUtils.split(containerName, "/");
		IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
		IResource resource = wsRoot.findMember(new Path("/" + names[0]));
		IPath loc = resource.getLocation();
		File prjLoc = new File(loc.toString());
		Collection<File> res = FileUtils.listFiles(prjLoc, FileFilterUtils.suffixFileFilter(ext, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE);
		for (File file : res)
			ret.add(file.getAbsolutePath());
	}
	return ret;
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:15,代码来源:PluginUtil.java

示例2: updatePlugin

import org.apache.commons.io.filefilter.FileFilterUtils; //导入依赖的package包/类
/**
 * 更新插件引擎
 * <p>
 * 检测脚本变化时更新
 * <p>
 * 当新插件引擎初始化成功之后再替换旧插件引擎
 *
 * @throws Exception
 */
private synchronized static void updatePlugin() throws Exception {
    // 清空 algorithm.config 配置
    Config.getConfig().setAlgorithmConfig("{}");
    boolean oldValue = HookHandler.enableHook.getAndSet(false);
    File pluginDir = new File(Config.getConfig().getScriptDirectory());
    LOGGER.debug("checker directory: " + pluginDir.getAbsolutePath());
    if (!pluginDir.isDirectory()) {
        pluginDir.mkdir();
    }
    File[] pluginFiles = pluginDir.listFiles((FileFilter) FileFilterUtils.suffixFileFilter(".js"));
    List<CheckScript> scripts = new LinkedList<CheckScript>();
    for (File file : pluginFiles) {
        try {
            scripts.add(new CheckScript(file));
        } catch (Exception e) {
            LOGGER.error("", e);
        }
    }

    JSContextFactory.setCheckScriptList(scripts);

    HookHandler.enableHook.set(oldValue);
}
 
开发者ID:baidu,项目名称:openrasp,代码行数:33,代码来源:JsPluginManager.java

示例3: 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

示例4: 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

示例5: 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

示例6: 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;
}
 
开发者ID:wsdookadr,项目名称:mdetect,代码行数:24,代码来源:FileScanUtils.java

示例7: findFilesToAnalyze

import org.apache.commons.io.filefilter.FileFilterUtils; //导入依赖的package包/类
public static List<String> findFilesToAnalyze(String dirPath) {
	IOFileFilter gitFilter = FileFilterUtils.notFileFilter(
					FileFilterUtils.nameFileFilter(".git")
			);
	File dir = new File(dirPath);
	String[] phpExt = new String[] {"php"};
	IOFileFilter phpFilter = new SuffixFileFilter(phpExt, IOCase.INSENSITIVE);
	List<File> files = (List<File>) FileUtils.listFiles(dir, phpFilter, gitFilter);
	List<String> results = new ArrayList<String>();
	for (File f : files) {
		try {
			results.add(f.getCanonicalPath());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	return results;
}
 
开发者ID:wsdookadr,项目名称:mdetect,代码行数:20,代码来源:FileScanUtils.java

示例8: getSubdirWithLatestCommit

import org.apache.commons.io.filefilter.FileFilterUtils; //导入依赖的package包/类
private File getSubdirWithLatestCommit(File rootDir) {
    File resultDir = rootDir;
    long latestTimestamp = GitUtil.getCheckedoutCommitTimestamp(rootDir);
    File [] dirs = rootDir.listFiles((FileFilter) FileFilterUtils.directoryFileFilter());
    if (dirs != null) {
        for (File dir : dirs) {
            logger.debug("  checking timestamp for '{}'", dir);
            long dirTimestamp = GitUtil.getCheckedoutCommitTimestamp(dir);
            if (dirTimestamp > latestTimestamp) {
                resultDir = dir;
                latestTimestamp = dirTimestamp;
            }
        }
    }
    return resultDir;
}
 
开发者ID:ctco,项目名称:gradle-mobile-plugin,代码行数:17,代码来源:ReportGitCommitInfoTask.java

示例9: getPackages

import org.apache.commons.io.filefilter.FileFilterUtils; //导入依赖的package包/类
@Override
public List<IPackage> getPackages() {
    String masterProjectActionPath = JapiClient.getConfig().getPrefixPath() + JapiClient.getConfig().getProjectJavaPath() + JapiClient.getConfig().getPostfixPath() + "/" + JapiClient.getConfig().getActionReletivePath();
    File actionFold = new File(masterProjectActionPath);
    if (!actionFold.exists()) {
        throw new JapiException(masterProjectActionPath + " fold not exists.");
    }
    final IOFileFilter dirFilter = FileFilterUtils.asFileFilter(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.isDirectory();
        }
    });
    Collection<File> folds = FileUtils.listFilesAndDirs(actionFold, dirFilter, TrueFileFilter.INSTANCE);
    List<IPackage> packages = new ArrayList<>(folds.size());
    for (File fold : folds) {
        if (!fold.getAbsolutePath().equals(actionFold.getAbsolutePath())) {
            PackageImpl packageImpl = new PackageImpl();
            packageImpl.setPackageFold(fold);
            packages.add(packageImpl);
        }
    }
    return packages;
}
 
开发者ID:dounine,项目名称:japi,代码行数:25,代码来源:ProjectImpl.java

示例10: getActions

import org.apache.commons.io.filefilter.FileFilterUtils; //导入依赖的package包/类
@Override
public List<IAction> getActions() {
    final IOFileFilter dirFilter = FileFilterUtils.asFileFilter(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.getName().endsWith(".java") && !pathname.getName().equals("package-info.java");
        }
    });
    Collection<File> actionFiles = FileUtils.listFiles(packageFold, dirFilter, null);
    List<IAction> actions = new ArrayList<>();
    for (File actionFile : actionFiles) {
        ActionImpl action = new ActionImpl();
        action.setActionFile(actionFile);
        actions.add(action);
    }
    return actions;
}
 
开发者ID:dounine,项目名称:japi,代码行数:18,代码来源:PackageImpl.java

示例11: importAttachments

import org.apache.commons.io.filefilter.FileFilterUtils; //导入依赖的package包/类
/**
 * Import attachments from backup folder
 */
private boolean importAttachments(File backupDir) {
    File attachmentsDir = StorageHelper.getAttachmentDir(this);
    // Moving back
    File backupAttachmentsDir = new File(backupDir, attachmentsDir.getName());
    if (!backupAttachmentsDir.exists()) return true;
    boolean result = true;
    Collection list = FileUtils.listFiles(backupAttachmentsDir, FileFilterUtils.trueFileFilter(),
            TrueFileFilter.INSTANCE);
    Iterator i = list.iterator();
    int imported = 0;
    File file = null;
    while (i.hasNext()) {
        try {
            file = (File) i.next();
            FileUtils.copyFileToDirectory(file, attachmentsDir, true);
            mNotificationsHelper.setMessage(TextHelper.capitalize(getString(R.string.attachment)) + " " + imported++ + "/" + list.size())
                    .show();
        } catch (IOException e) {
            result = false;
            Log.e(Constants.TAG, "Error importing the attachment " + file.getName());
        }
    }
    return result;
}
 
开发者ID:ApplicationFactory,项目名称:PEP---Notes,代码行数:28,代码来源:DataBackupIntentService.java

示例12: run

import org.apache.commons.io.filefilter.FileFilterUtils; //导入依赖的package包/类
private void run() throws ResourceInitializationException, IOException, SAXException {
    Collection<File> inputFiles =
            FileUtils.listFiles(inputDir, FileFilterUtils.suffixFileFilter(".xml"), null);
    if (inputFiles.isEmpty()) {
        return;
    }
    TypeSystemDescription tsd = TypeSystemDescriptionFactory
            .createTypeSystemDescription(typeSystemDescName);
    CAS cas = CasCreationUtils.createCas(tsd, null, null);
    for (File inputFile : inputFiles) {
        AXMLReader.read(inputFile, cas);
        File outFile = getOutputFile(inputFile);
        OutputStream out = FileUtils.openOutputStream(outFile);
        try {
            XmiCasSerializer.serialize(cas, null, out, true, null);
        } finally {
            out.close();
            cas.reset();
        }
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:22,代码来源:AXML2XMI.java

示例13: initialize

import org.apache.commons.io.filefilter.FileFilterUtils; //导入依赖的package包/类
@Override
public void initialize(UimaContext ctx) throws ResourceInitializationException {
    super.initialize(ctx);
    // initialize mappingFactory
    mappingFactory = InitializableFactory.create(ctx, mappingFactoryClassName,
            BratUimaMappingFactory.class);
    // make bratDocIter
    File[] annFiles = bratCollectionDir.listFiles(
            (FileFilter) FileFilterUtils.suffixFileFilter(BratDocument.ANN_FILE_SUFFIX));
    List<BratDocument> bratDocs = Lists.newArrayListWithExpectedSize(annFiles.length);
    for (File annFile : annFiles) {
        String docBaseName = FilenameUtils.getBaseName(annFile.getPath());
        BratDocument bratDoc = new BratDocument(bratCollectionDir, docBaseName);
        if (bratDoc.exists()) {
            bratDocs.add(bratDoc);
        } else {
            throw new IllegalStateException(String.format(
                    "Missing txt file for %s", annFile));
        }
    }
    totalDocsNum = bratDocs.size();
    bratDocIter = bratDocs.iterator();
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:24,代码来源:BratCollectionReader.java

示例14: 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);
  }
}
 
开发者ID:axonivy,项目名称:project-build-plugin,代码行数:19,代码来源:FileLogForwarder.java

示例15: removeCustomDLC

import org.apache.commons.io.filefilter.FileFilterUtils; //导入依赖的package包/类
/**
 * Deletes all non-standard DLC folders from the BioGAme/DLC directory
 * using the known list of DLCs
 */
private boolean removeCustomDLC() {
	// TODO Auto-generated method stub
	File rootFolder = new File(ModManager.appendSlash(RestoreFilesWindow.this.BioGameDir) + "DLC");
	if (rootFolder.exists()) {
		File[] folders = rootFolder.listFiles((FileFilter) FileFilterUtils.directoryFileFilter());
		for (File dlcfolder : folders) {
			String foldername = dlcfolder.getName();
			if (!ModTypeConstants.getStandardDLCFolders().contains(foldername)) {
				try {
					FileUtils.deleteDirectory(dlcfolder);
					ModManager.debugLogger.writeMessage("Deleted DLC folder: " + dlcfolder.getAbsolutePath());
				} catch (IOException e) {
					ModManager.debugLogger.writeErrorWithException("Unabled to delete DLC folder: " + dlcfolder, e);
					return false;
				}
			}
		}

		ModManager.debugLogger.writeMessage("Deleted all Custom DLC folders (if there were any)");
		publish(Integer.toString(completed));
		return true;
	} else {
		return false;
	}
}
 
开发者ID:Mgamerz,项目名称:me3modmanager,代码行数:30,代码来源:RestoreFilesWindow.java


注:本文中的org.apache.commons.io.filefilter.FileFilterUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。