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


Java TrueFileFilter.INSTANCE属性代码示例

本文整理汇总了Java中org.apache.commons.io.filefilter.TrueFileFilter.INSTANCE属性的典型用法代码示例。如果您正苦于以下问题:Java TrueFileFilter.INSTANCE属性的具体用法?Java TrueFileFilter.INSTANCE怎么用?Java TrueFileFilter.INSTANCE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.io.filefilter.TrueFileFilter的用法示例。


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

示例1: DirectoryMonitor

public DirectoryMonitor(String directorypath, long polling, String classname) {

        this.directory = new File(directorypath);
        this.trackedClassName = classname;
        this.polling = polling;

        if (!directory.isDirectory()) {
            LOG.info("Monitored directory {} not existing - creating directory", directory.getAbsolutePath());
            if (!this.directory.mkdirs()) {
                throw new IllegalStateException("Monitored directory doesn't exist and cannot be created.");
            }
        }

        // We observes all files.
        FileAlterationObserver observer = new FileAlterationObserver(directory, TrueFileFilter.INSTANCE);
        observer.checkAndNotify();
        observer.addListener(new FileMonitor());
        monitor = new FileAlterationMonitor(polling, observer);

    }
 
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:20,代码来源:DirectoryMonitor.java

示例2: findFiles

/**
 * Find files matching the pattern in the given directory and returns their java.io.File objects as array.
 *
 * @param dirAbsPath Absolute path of the directory.
 * @param fileNamePattern Regular expression for the file name pattern
 * @param recursive Boolean indicating whether recursive search to be made or not while finding the files.
 * @return the file[]. Returns null if either dirAbsPath is null or fileNamePattern is null or fileNamePattern is
 *         not a valid regular expression or no files matching the pattern found.
 */
public static File[] findFiles( final String dirAbsPath, final String fileNamePattern, boolean recursive )
{

    // check that dirAbsPath and fileNamePattern are not null or blank
    if ( StringUtils.isBlank( dirAbsPath ) || StringUtils.isBlank( fileNamePattern ) )
    {
        logger.warn( "In findFiles, either directory or file name pattern is null or blank."
            + " Directory: {}, FileNamePattern: {}.", dirAbsPath, fileNamePattern );
        return null;
    }

    // check that file name pattern is a valid pattern.
    if ( !FileUtil.isValidPattern( fileNamePattern ) )
    {
        logger.warn( "In findFiles, file name pattern '{}' is not a valid pattern.", fileNamePattern );
        return null;
    }

    // check that directory exists and is a directory.
    File dir = new File( dirAbsPath );
    if ( !dir.exists() || !dir.isDirectory() )
    {
        logger.warn( "In findFiles, either directory '{}' does not exists or not a directory.", dirAbsPath );
        return null;
    }
    IOFileFilter dirFilter = recursive ? TrueFileFilter.INSTANCE : null;
    Collection<File> files = FileUtils.listFiles( dir, new RegexFileFilter( fileNamePattern ), dirFilter );
    if ( files == null || files.size() == 0 )
    {
        logger.warn( "In findLatestFileByLastModified, no files found matching pattern '{}' in directory '{}'.",
                     fileNamePattern, dirAbsPath );
        return null;
    }
    return files.toArray( new File[files.size()] );
}
 
开发者ID:vmware,项目名称:OHMS,代码行数:44,代码来源:FileUtil.java

示例3: run

private void run() throws Exception {
    IOFileFilter corpusFileFilter;
    if (corpusFileSuffix == null) {
        corpusFileFilter = FileFilterUtils.trueFileFilter();
    } else {
        corpusFileFilter = FileFilterUtils.suffixFileFilter(corpusFileSuffix);
    }
    IOFileFilter corpusSubDirFilter = includeSubDirectores ? TrueFileFilter.INSTANCE : null;
    List<Set<File>> partitions = Lists.newArrayList(CorpusUtils.partitionCorpusByFileSize(
            corpusDir, corpusFileFilter, corpusSubDirFilter, partitionsNum));
    if (partitions.size() != partitionsNum) {
        throw new IllegalStateException();
    }
    // make dev partition from the last because it is a little bit smaller
    Set<File> devFiles = getAndRemove(partitions, partitions.size() - 1);
    Set<File> testFiles = getAndRemove(partitions, partitions.size() - 1);
    Set<File> trainFiles = Sets.newLinkedHashSet();
    for (Set<File> s : partitions) {
        trainFiles.addAll(s);
    }
    // write files
    File devPartFile = new File(outputDir, CorpusUtils.getDevPartitionFilename(0));
    FileUtils.writeLines(devPartFile, "utf-8", CorpusUtils.toRelativePaths(corpusDir, devFiles));
    File testPartFile = new File(outputDir, CorpusUtils.getTestPartitionFilename(0));
    FileUtils.writeLines(testPartFile, "utf-8", CorpusUtils.toRelativePaths(corpusDir, testFiles));
    File trainPartFile = new File(outputDir, CorpusUtils.getTrainPartitionFilename(0));
    FileUtils.writeLines(trainPartFile, "utf-8", CorpusUtils.toRelativePaths(corpusDir, trainFiles));
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:28,代码来源:TrainDevTestCorpusSplitter.java

示例4: run

private void run() throws Exception {
    IOFileFilter corpusFileFilter;
    if (corpusFileSuffix == null) {
        corpusFileFilter = FileFilterUtils.trueFileFilter();
    } else {
        corpusFileFilter = FileFilterUtils.suffixFileFilter(corpusFileSuffix);
    }
    IOFileFilter corpusSubDirFilter = includeSubDirectores ? TrueFileFilter.INSTANCE : null;
    List<CorpusSplit> corpusSplits = CorpusUtils.createCrossValidationSplits(corpusDir,
            corpusFileFilter, corpusSubDirFilter, foldNum);
    for (int i = 0; i < corpusSplits.size(); i++) {
        writeFileLists(outputDir, i, corpusSplits.get(i));
    }
}
 
开发者ID:textocat,项目名称:textokit-core,代码行数:14,代码来源:CrossValidationCorpusSplitter.java

示例5: watch

/**
 * Starts the watching.
 *
 * @return the current pipeline.
 */
public Pipeline watch() {
    // Delete all error reports before starting the watcher.
    error = new File(baseDir, "target/pipeline");
    FileUtils.deleteQuietly(error);
    mojo.getLog().debug("Creating the target/pipeline directory : " + error.mkdirs());

    // Start the watching process.
    watcher = new FileAlterationMonitor(Integer.getInteger("watch.period", 2) * 1000);
    watcher.setThreadFactory(new DefensiveThreadFactory("wisdom-pipeline-watcher", mojo));
    FileAlterationObserver srcObserver = new FileAlterationObserver(new File(baseDir, "src"),
            TrueFileFilter.INSTANCE);
    PipelineWatcher listener = new PipelineWatcher(this);
    srcObserver.addListener(listener);
    watcher.addObserver(srcObserver);

    if (pomFileMonitoring) {
        FileAlterationObserver pomObserver = new FileAlterationObserver(baseDir, new FileFilter() {
            @Override
            public boolean accept(File file) {
                return file.equals(new File(baseDir, "pom.xml"));
            }
        });
        pomObserver.addListener(listener);
        watcher.addObserver(pomObserver);
    }

    try {
        mojo.getLog().info("Start watching " + baseDir.getAbsolutePath());
        watcher.start();
    } catch (Exception e) {
        mojo.getLog().error("Cannot start the watcher", e);
    }
    return this;
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:39,代码来源:Pipeline.java


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