本文整理汇总了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);
}
示例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()] );
}
示例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));
}
示例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));
}
}
示例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;
}