List of usage examples for org.apache.commons.io.filefilter TrueFileFilter INSTANCE
IOFileFilter INSTANCE
To view the source code for org.apache.commons.io.filefilter TrueFileFilter INSTANCE.
Click Source Link
From source file:com.mindquarry.desktop.workspace.SVNSynchronizer.java
/** * Like synchronize(), but does a checkout if <tt>localPath</tt> isn't a * checkout. Also, creates the path if it doesn't exist. * //from w ww. j a v a 2 s. co m * @throws SynchronizeException */ // TODO: make a difference between user cancelled and synch aborted due // to some other error public void synchronizeOrCheckout() throws SynchronizeException { log.debug("synchronizeOrCheckout on " + localPathFile.getAbsolutePath()); // if directory doesn't exist, create it: if (!localPathFile.exists()) { boolean createdDir = localPathFile.mkdirs(); if (!createdDir) { throw new RuntimeException("Could not create directory: " + localPathFile.getAbsolutePath()); } } if (localPathFile.isFile()) { throw new IllegalArgumentException( "File where directory " + "was expected: " + localPathFile.getAbsolutePath()); } boolean isCheckedOut = isCheckedOut(localPathFile); if (isCheckedOut) { // already check out, sync it synchronize(); } else { // check if the directories are empty, // otherwise we'd try to check out into a directory // that contains local files already which causes // confusion. Iterator iter = FileUtils.iterateFiles(localPathFile, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); if (iter.hasNext()) { throw new SynchronizeException("Cannot initially checkout into '" + localPathFile.getAbsolutePath() + "' because it seems not empty."); } else { try { log.debug("checkout " + repositoryURL + " to " + localPathFile.getAbsolutePath()); client.checkout(repositoryURL, localPathFile.getAbsolutePath(), Revision.HEAD, true); } catch (ClientException e) { throw new RuntimeException( "Checkout of " + repositoryURL + " to " + localPathFile.getAbsolutePath() + " failed", e); } } } }
From source file:hoot.services.controllers.info.ReportsResource.java
protected JSONArray _getReportsList() throws Exception { JSONArray res = new JSONArray(); // sort by name Map<String, JSONObject> sorted = new TreeMap<String, JSONObject>(); String storePath = _homeFolder + "/" + _rptStorePath; File f = new File(storePath); if (f.exists()) { List<File> files = (List<File>) FileUtils.listFilesAndDirs(f, new NotFileFilter(TrueFileFilter.INSTANCE), DirectoryFileFilter.DIRECTORY); for (File file : files) { try { if (file.isDirectory()) { String id = file.getName(); String absPath = file.getAbsolutePath(); if (!absPath.equals(storePath)) { JSONObject meta = _getMetaData(id); meta.put("id", id); sorted.put(meta.get("name").toString(), meta); }//from www . ja va 2 s. c o m } } catch (Exception ee) { // we ignore and continue log.error(ee.getMessage()); } } } res.addAll(sorted.values()); return res; }
From source file:com.github.blindpirate.gogradle.util.IOUtils.java
public static Collection<File> listAllDescendents(File dir) { return FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); }
From source file:edu.wisc.doit.tcrypt.ant.filter.AntTasksTest.java
private Map<String, File> getAllFiles(File dir) throws Exception { final Collection<File> expectedFiles = FileUtils.listFilesAndDirs(dir, TrueFileFilter.INSTANCE, DirectoryFileFilter.INSTANCE); final Map<String, File> result = new HashMap<String, File>(); for (final File f : expectedFiles) { final String relativePath = org.apache.tools.ant.util.FileUtils.getRelativePath(dir, f); result.put(relativePath, f);/*from w w w. ja va 2s . co m*/ } return result; }
From source file:bioLockJ.module.classifier.r16s.QiimeClassifier.java
/** * Subclasses call this method to input files to only those named OTU_TABLE in dir (and its subdirs). *//*from w w w.jav a 2 s .c o m*/ @Override protected void initInputFiles(final File dir) throws Exception { Log.out.info("Get input files from " + getDirName(dir) + " named: " + OTU_TABLE); final IOFileFilter ff = new NameFileFilter(OTU_TABLE); setModuleInput(dir, ff, TrueFileFilter.INSTANCE); }
From source file:de.cosmocode.palava.store.FileSystemStore.java
@Override public Set<String> list() throws IOException { final IOFileFilter fileFilter = FileFilterUtils.fileFileFilter(); final IOFileFilter directoryFilter = TrueFileFilter.INSTANCE; @SuppressWarnings("unchecked") final Collection<File> files = FileUtils.listFiles(directory, fileFilter, directoryFilter); return Sets.newHashSet(Collections2.transform(files, toIdentifier)); }
From source file:com.jalios.ejpt.sync.utils.IOUtil.java
public static File findPluginXMLFile(File directory) throws FileNotFoundException { Collection<File> files = FileUtils.listFiles(directory, FileFilterUtils.nameFileFilter(ParseConstants.PLUGIN_XML), TrueFileFilter.INSTANCE); if (!files.isEmpty() && files.size() == 1) { return files.iterator().next(); }/* w w w . j a v a2s. c om*/ throw new FileNotFoundException("'plugin.xml' not found in " + directory); }
From source file:de.uzk.hki.da.model.WorkArea.java
/** * Gets the files of a representation. Operates on the basis of the FS. * @param repName//from ww w .j ava 2 s .c om * @return */ private Collection<File> getFilesOfRepresentationFS(String repName) { return FileUtils.listFiles(Path.makeFile(Path.make(objectPath(), "data"), repName), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); }
From source file:com.badlogicgames.packr.PackrReduce.java
static void removePlatformLibs(PackrOutput output, PackrConfig config) throws IOException { System.out.println("Removing foreign platform libs ..."); // let's remove any shared libs not used on the platform, e.g. libGDX/LWJGL natives for (String classpath : config.classpath) { File jar = new File(output.resourcesFolder, new File(classpath).getName()); File jarDir = new File(output.resourcesFolder, jar.getName() + ".tmp"); if (config.verbose) { if (jar.isDirectory()) { System.out.println(" # Classpath '" + classpath + "' is a directory"); } else { System.out.println(" # Unpacking '" + classpath + "' ..."); }/*from www . jav a 2 s. co m*/ } if (!jar.isDirectory()) { ZipUtil.unpack(jar, jarDir); } Set<String> extensions = new HashSet<String>(); switch (config.platform) { case Windows32: case Windows64: extensions.add(".dylib"); extensions.add(".so"); break; case Linux32: case Linux64: extensions.add(".dylib"); extensions.add(".dll"); break; case MacOS: extensions.add(".dll"); extensions.add(".so"); break; } for (Object obj : FileUtils.listFiles(jarDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) { File file = new File(obj.toString()); for (String extension : extensions) { if (file.getName().endsWith(extension)) { if (config.verbose) { System.out.println(" # Removing '" + file.getPath() + "'"); } PackrFileUtils.delete(file); } } } if (!jar.isDirectory()) { if (config.verbose) { System.out.println(" # Repacking '" + classpath + "' ..."); } long beforeLen = jar.length(); PackrFileUtils.delete(jar); ZipUtil.pack(jarDir, jar); FileUtils.deleteDirectory(jarDir); long afterLen = jar.length(); if (config.verbose) { System.out.println(" # " + beforeLen / 1024 + " kb -> " + afterLen / 1024 + " kb"); } } } }
From source file:com.drunkendev.io.recurse.tests.RecursionTest.java
/** * Answer provided by Bozho.//w w w . j a v a2 s . c o m * * Tests using <a href="https://commons.apache.org/proper/commons-io/">Apache commons-io</a> * {@link FileUtils#iterateFilesAndDirs(File, IOFileFilter, IOFileFilter)} * which uses the {@link java.io.File} API. * * @see <a href="http://stackoverflow.com/a/2056258/140037">Stack-Overflow answer by Bozho</a> */ // @Test public void testFileUtils() { System.out.println("\nTEST: commons-io - FileUtils"); time(() -> { Iterator<File> iter = FileUtils.iterateFilesAndDirs(startPath.toFile(), TrueFileFilter.INSTANCE, new IOFileFilter() { @Override public boolean accept(File file) { try { return isPlainDir(file); } catch (IOException ex) { return false; } } @Override public boolean accept(File dir, String name) { try { return isPlainDir(dir); } catch (IOException ex) { return false; } } }); int files = 0; int dirs = 0; File n; try { while (iter.hasNext()) { n = iter.next(); if (isPlainDir(n)) { dirs++; } else { files++; } } System.out.format("Files: %d, dirs: %d. ", files, dirs); } catch (IOException ex) { fail(ex.getMessage()); } }); }