List of usage examples for org.apache.commons.io.filefilter CanReadFileFilter CAN_READ
IOFileFilter CAN_READ
To view the source code for org.apache.commons.io.filefilter CanReadFileFilter CAN_READ.
Click Source Link
From source file:com.moneydance.modules.features.importlist.io.DirectoryValidator.java
@Override public boolean accept(final File file) { try {/*from w w w. java2s . co m*/ return FileFilterUtils.and(CanReadFileFilter.CAN_READ, FileFilterUtils.directoryFileFilter()) .accept(file); } catch (SecurityException e) { LOG.log(Level.WARNING, e.getMessage(), e); return false; } }
From source file:com.moneydance.modules.features.importlist.io.FileAdmin.java
public FileAdmin(final String baseDirectory, final FeatureModuleContext argContext) { this.localizable = Helper.INSTANCE.getLocalizable(); this.context = argContext; if (SystemUtils.IS_OS_MAC) { this.directoryChooser = new MacOSDirectoryChooser(baseDirectory); } else {/*from w w w . j a va 2 s. c o m*/ this.directoryChooser = new DefaultDirectoryChooser(baseDirectory); } this.directoryValidator = DirectoryValidator.INSTANCE; this.transactionFileFilter = new SuffixFileFilter( Helper.INSTANCE.getSettings().getTransactionFileExtensions(), IOCase.INSENSITIVE); this.textFileFilter = new SuffixFileFilter(Helper.INSTANCE.getSettings().getTextFileExtensions(), IOCase.INSENSITIVE); this.readableFileFilter = FileFilterUtils.and(CanReadFileFilter.CAN_READ, FileFilterUtils.or(this.transactionFileFilter, this.textFileFilter)); this.listener = new TransactionFileListener(); this.listener.addObserver(this); this.monitor = new FileAlterationMonitor(Helper.INSTANCE.getSettings().getMonitorInterval()); this.files = Collections.synchronizedList(new ArrayList<File>()); }
From source file:net.roboconf.dm.templating.internal.templates.TemplateWatcher.java
/** * Constructor./* ww w.ja va 2s .c o m*/ * @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."); }
From source file:ijfx.core.imagedb.DefaultExplorerService.java
public static IOFileFilter canReadFilter(IOFileFilter filter) { return new AndFileFilter(filter, CanReadFileFilter.CAN_READ); }
From source file:de.dentrassi.build.apt.repo.AptWriter.java
public void build() throws Exception { if (this.configuration.getTargetFolder().exists()) { throw new IllegalStateException( "The target path must not exists: " + this.configuration.getTargetFolder()); }//from w w w . j a v a2 s. co m if (!this.configuration.getSourceFolder().isDirectory()) { throw new IllegalStateException( "The source path must exists and must be a directory: " + this.configuration.getTargetFolder()); } this.configuration.validate(); this.configuration.getTargetFolder().mkdirs(); this.pool = new File(this.configuration.getTargetFolder(), "pool"); this.dists = new File(this.configuration.getTargetFolder(), "dists"); this.pool.mkdirs(); this.dists.mkdirs(); final FileFilter debFilter = new AndFileFilter( // Arrays.asList( // CanReadFileFilter.CAN_READ, // FileFileFilter.FILE, // new SuffixFileFilter(".deb") // ) // ); for (final File packageFile : this.configuration.getSourceFolder().listFiles(debFilter)) { processPackageFile(packageFile); } writePackageLists(); }
From source file:net.roboconf.dm.templating.internal.templates.TemplateWatcher.java
@Override public void onStart(final FileAlterationObserver observer) { if (this.alreadyStarted.getAndSet(true)) return;//from w w w . j a v a2s . c o m 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); }
From source file:org.jclouds.examples.blobstore.BlobUploaderMain.java
public static void main(String[] args) throws IOException { OptionParser parser = new OptionParser(); parser.accepts("directory").withRequiredArg().required().ofType(String.class); parser.accepts("provider").withRequiredArg().required().ofType(String.class); parser.accepts("username").withRequiredArg().required().ofType(String.class); parser.accepts("password").withRequiredArg().required().ofType(String.class); parser.accepts("region").withRequiredArg().required().ofType(String.class); parser.accepts("threads").withRequiredArg().ofType(Integer.TYPE).describedAs("number of parallel threads"); OptionSet options = null;//from w ww . j a v a2s . c om try { options = parser.parse(args); } catch (OptionException e) { System.out.println(e.getLocalizedMessage()); parser.printHelpOn(System.out); return; } if (options.has("threads")) { numThreads = Integer.valueOf((String) options.valueOf("numThreads")); } File rootDir = new File((String) options.valueOf("directory")); Collection<File> files = FileUtils.listFiles(rootDir, CanReadFileFilter.CAN_READ, TrueFileFilter.TRUE); totalBytes = FileUtils.sizeOfDirectory(rootDir); System.out.println("Uploading " + rootDir.getName() + " " + totalBytes / FileUtils.ONE_MB + "MB"); ExecutorService executor = Executors.newFixedThreadPool(numThreads); for (File f : files) { BlobUploader b = new BlobUploader((String) options.valueOf("username"), (String) options.valueOf("password"), (String) options.valueOf("provider"), (String) options.valueOf("region"), f); executor.execute(b); } executor.shutdown(); try { executor.awaitTermination(1, TimeUnit.DAYS); } catch (InterruptedException e) { e.printStackTrace(); } }