Java 类org.apache.commons.io.filefilter.CanReadFileFilter 实例源码

项目:roboconf-platform    文件:TemplateWatcher.java   
@Override
public void onStart( final FileAlterationObserver observer ) {

    if( this.alreadyStarted.getAndSet( true ))
        return;

    this.logger.fine("Initial provisioning of templates...");
    final Collection<File> templateFiles = FileUtils.listFiles(
            this.templateDir,

            // Find readable template files.
            FileFilterUtils.and(
                    FileFilterUtils.suffixFileFilter( ".tpl" ),
                    CanReadFileFilter.CAN_READ),

            // Directory filter: go through the root template directory and its direct children.
            new TemplateDirectoryFileFilter( this.templateDir ));

    process( templateFiles );
}
项目:censustaker    文件:PropertiesCensus.java   
private static void pollSysctl(Map<String, JsonElement> results) {
  Map<String, String> sysctls = new HashMap<>();

  Collection<File> files = FileUtils.listFiles(new File("/proc/sys"), CanReadFileFilter.CAN_READ, DirectoryFileFilter.DIRECTORY);
  for (File file : files) {
    String sysctl = file.getAbsolutePath().replaceAll("^/proc/sys/", "").replaceAll("/", ".");
    try {
      String contents = FileUtils.readFileToString(file, "UTF8");
      contents = contents.replaceAll("\n$", "");
      sysctls.put(sysctl, contents);
    } catch (IOException e) {
      Log.e("censustaker", "Failed to read " + file + ": " + e.toString());
      e.printStackTrace();
    }
  }

  results.put("sysctl", gson.toJsonTree(sysctls, sysctls.getClass()));
}
项目:roboconf-platform    文件:TemplateWatcher.java   
/**
 * 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." );
}
项目:rippletx    文件:Application.java   
/**
 * Returns all the files in a directory.
 * 
 * @param dir
 *            - Path to the directory that contains the text documents to be
 *            parsed.
 * @return A collection of File Objects
 */
public static Collection<File> getFolderContents(String dir)
{
    // Collect all readable documents
    File file = new File(dir);
    Collection<File> files = FileUtils.listFiles(file, CanReadFileFilter.CAN_READ, DirectoryFileFilter.DIRECTORY);
    return files;
}
项目:btcviz    文件:Application.java   
/**
 * Returns all the files in a directory.
 * 
 * @param dir
 *            - Path to the directory that contains the text documents to be
 *            parsed.
 * @return A collection of File Objects
 */
public static Collection<File> getFolderContents(String dir)
{
    // Collect all readable documents
    File file = new File(dir);
    Collection<File> files = FileUtils.listFiles(file, CanReadFileFilter.CAN_READ, DirectoryFileFilter.DIRECTORY);
    return files;
}
项目:allure1    文件:AllureFileUtils.java   
/**
 * Returns list of files matches specified regex in specified directories
 *
 * @param regex       to match file names
 * @param directories to find
 * @return list of files matches specified regex in specified directories
 */
public static List<File> listFilesByRegex(String regex, File... directories) {
    return listFiles(directories,
            new RegexFileFilter(regex),
            CanReadFileFilter.CAN_READ);
}