List of usage examples for java.io FileFilter FileFilter
FileFilter
From source file:com.autburst.picture.Utilities.java
public static boolean hasAnyAlbumPics() { File file = getAlbumsDirectory(); File[] list = file.listFiles(); if (list == null) return false; for (File file2 : list) { if (file2.listFiles(new FileFilter() { @Override//from w w w . j av a2 s. com public boolean accept(File arg0) { String name = arg0.getName(); if (name.endsWith(".jpg") || name.endsWith(".JPG")) return true; else return false; } }).length > 0) return true; } return false; }
From source file:com.sap.prd.mobile.ios.mios.XCodeCopySourcesMojo.java
@Override public void execute() throws MojoExecutionException, MojoFailureException { final File baseDirectory = getCanonicalFile(project.getBasedir()); final File checkoutDirectory = getCanonicalFile(getCheckoutDirectory()); final String buildDirPath = getProjectBuildDirectory(); getLog().info("Base directory: " + baseDirectory); getLog().info("Checkout directory: " + checkoutDirectory); getLog().info("BuildDirPath: " + buildDirPath); final File originalLibDir = getCanonicalFile( new File(project.getBuild().getDirectory(), FolderLayout.LIBS_DIR_NAME)); final File copyOfLibDir = getCanonicalFile( new File(checkoutDirectory, buildDirPath + "/" + FolderLayout.LIBS_DIR_NAME)); final File originalHeadersDir = getCanonicalFile( new File(project.getBuild().getDirectory(), FolderLayout.HEADERS_DIR_NAME)); final File copyOfHeadersDir = getCanonicalFile( new File(checkoutDirectory, buildDirPath + "/" + FolderLayout.HEADERS_DIR_NAME)); final File originalXcodeDepsDir = getCanonicalFile( new File(project.getBuild().getDirectory(), FolderLayout.XCODE_DEPS_TARGET_FOLDER)); final File copyOfXcodeDepsDir = getCanonicalFile( new File(checkoutDirectory, buildDirPath + "/" + FolderLayout.XCODE_DEPS_TARGET_FOLDER)); try {//from ww w . jav a 2 s .co m if (checkoutDirectory.exists()) com.sap.prd.mobile.ios.mios.FileUtils.deleteDirectory(checkoutDirectory); copy(baseDirectory, checkoutDirectory, new FileFilter() { @Override public boolean accept(final File pathname) { final File canonicalPathName = getCanonicalFile(pathname); return !(checkoutDirectory.equals(canonicalPathName) || originalLibDir.equals(canonicalPathName) || originalHeadersDir.equals(canonicalPathName) || originalXcodeDepsDir.equals(canonicalPathName)); } }); if (originalLibDir.exists()) { if (useSymbolicLinks()) { com.sap.prd.mobile.ios.mios.FileUtils.createSymbolicLink(originalLibDir, copyOfLibDir); } else { FileUtils.copyDirectory(originalLibDir, copyOfLibDir); } } if (originalHeadersDir.exists()) { if (useSymbolicLinks) { com.sap.prd.mobile.ios.mios.FileUtils.createSymbolicLink(originalHeadersDir, copyOfHeadersDir); } else { FileUtils.copyDirectory(originalHeadersDir, copyOfHeadersDir); } } if (originalXcodeDepsDir.exists()) { if (useSymbolicLinks) { com.sap.prd.mobile.ios.mios.FileUtils.createSymbolicLink(originalXcodeDepsDir, copyOfXcodeDepsDir); } else { FileUtils.copyDirectory(originalXcodeDepsDir, copyOfXcodeDepsDir); } } } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); } }
From source file:de.tudarmstadt.ukp.dkpro.spelling.io.HOOReader.java
@Override public void initialize(UimaContext aContext) throws ResourceInitializationException { super.initialize(aContext); // get all the edit files editFiles = editsPath.listFiles(new FileFilter() { @Override//from w w w.j a v a 2 s .co m public boolean accept(File pathname) { if (pathname.isFile() && pathname.getName().endsWith(".xml")) { return true; } return false; } }); }
From source file:com.amazonaws.eclipse.core.accounts.profiles.SdkCredentialsFileContentMonitor.java
public SdkCredentialsFileContentMonitor(File target, long pollingIntervalInMillis, FileAlterationListener listener) { _target = target;/* w w w .j a v a 2 s. c o m*/ // IllegalArgumentException is expected if target.getParentFile == null _observer = new FileAlterationObserver(target.getParentFile(), new FileFilter() { public boolean accept(File file) { return file.equals(_target); } }); _monitor = new FileAlterationMonitor(pollingIntervalInMillis); _listener = listener; _observer.addListener(_listener); _monitor.addObserver(_observer); // Use daemon thread to avoid thread leakage _monitor.setThreadFactory(new ThreadFactory() { public Thread newThread(Runnable runnable) { Thread t = new Thread(runnable); t.setDaemon(true); t.setName("aws-credentials-file-monitor-thread"); return t; } }); }
From source file:net.dmulloy2.ultimatearena.api.ArenaTypeHandler.java
public final void loadArenaTypes() { File directory = new File(plugin.getDataFolder(), "types"); if (!directory.exists()) directory.mkdirs();//from w w w . j av a2s . c o m ArenaLoader loader = new ArenaLoader(plugin); // Add default types loadArenaType(new BombType()); loadArenaType(new ConquestType()); loadArenaType(new CTFType()); loadArenaType(new FFAType()); loadArenaType(new HungerType()); loadArenaType(new InfectType()); loadArenaType(new KOTHType()); loadArenaType(new MobType()); loadArenaType(new PvPType()); loadArenaType(new SpleefType()); // Load custom types File[] files = directory.listFiles(new FileFilter() { @Override public boolean accept(File file) { return file.getName().endsWith(".jar"); } }); if (files != null && files.length > 0) { for (File file : files) { loadArenaType(loader, file); } } }
From source file:de.codesourcery.eve.apiclient.cache.FilesystemResponseCacheTest.java
@Override protected void tearDown() throws Exception { super.tearDown(); if (tmpDir == null) { return;/*from w ww. j a va2s . c om*/ } final FileFilter filter = new FileFilter() { @Override public boolean accept(File pathname) { return pathname.isFile() && pathname.getName().endsWith(".xml"); } }; for (File f : tmpDir.listFiles(filter)) { f.delete(); } tmpDir.delete(); }
From source file:com.mkl.websuites.internal.tests.ScenarioFolderTest.java
private void processRecursivelyFolder(Path folderPath, TestSuite parentSuite) { TestSuite currentFolderSuite;/*from www . j a v a 2s. co m*/ if (isTopTest) { currentFolderSuite = new TestSuite(folderPath.toString()); isTopTest = false; } else { currentFolderSuite = new TestSuite( folderPath.subpath(folderPath.getNameCount() - 1, folderPath.getNameCount()).toString()); } List<Test> testsInCurrentFolder = processScenarioFilesInFolder(folderPath.toString()); for (Test test : testsInCurrentFolder) { currentFolderSuite.addTest(test); } parentSuite.addTest(currentFolderSuite); if (ignoreSubfolders) { return; } File folder = new File(folderPath.toString()); File[] nestedFolders = folder.listFiles(new FileFilter() { @Override public boolean accept(File file) { return file.isDirectory(); } }); if (nestedFolders == null) { throw new WebServiceException(String.format("Error while traversing through folder " + "structure starting from path '%s'. Probably there is something wrong " + "in the path string.", folderPath)); } sort(nestedFolders); for (File nested : nestedFolders) { processRecursivelyFolder(Paths.get(nested.toURI()), currentFolderSuite); } }
From source file:org.jasig.openregistry.core.repository.XmlSystemOfRecordRepository.java
public void reload() { logger.info("There are currently [" + soRSpecifications.size() + "] specs loaded. Reloading now."); final List<SoRSpecification> soRSpecifications = new ArrayList<SoRSpecification>(); for (final File file : this.file.listFiles(new FileFilter() { public boolean accept(final File file) { return file.getName().endsWith(".xml"); }// w w w . j a va 2 s .c om })) { final SoRSpecification soRSpecification = loadSoRSpecificationFromFile(file); if (soRSpecification != null) { soRSpecifications.add(soRSpecification); } } this.soRSpecifications = soRSpecifications; }
From source file:gr.demokritos.biographs.indexing.databases.TrieDatabase.java
/** * Builds a graph database index from a given file or a directory * of files./*from www. j a v a 2 s. com*/ * * @param fPath a path containing one or multiple files */ @Override public void buildIndex(File fPath) throws Exception { if (!fPath.isDirectory()) { addAllGraphs(fPath); } else { /* get all files in a list, and for each file add all * the resulting biographs to the database */ File[] fileList = fPath.listFiles(new FileFilter() { public boolean accept(File toFilter) { return toFilter.isFile(); } }); for (File f : fileList) { addAllGraphs(f); } } }
From source file:gov.va.vinci.leo.tools.LeoUtils.java
/** * Return a list of File Objects in a directory. Optionally return only a list of Files * that match the given FileFilter. Recurse into subdirectories if indicated. If no filter * is provided then return all the files in the directory. * * @param src Source directory where the search will be performed. * @param filter Optional, File filter to limit results that are returned. * @param recurse If true then recurse into subdirectories, only return this directory results if false * @return List of File objects found in this directory *///from w w w .j a v a 2s. c om public static List<File> listFiles(File src, FileFilter filter, boolean recurse) { List<File> files = new ArrayList<File>(); if (src == null || !src.exists() || src.isFile()) { return files; } //if //Get the list of files, apply the filter if provided File[] fileList = (filter != null) ? src.listFiles(filter) : src.listFiles(); for (File f : fileList) { if (!files.contains(f)) { files.add(f); } } //for //Recurse through the list of directories if (recurse) { FileFilter dirFilter = new FileFilter() { @Override public boolean accept(File f) { return f.isDirectory(); }//accept method }; File[] dirList = src.listFiles(dirFilter); for (File f : dirList) { files.addAll(listFiles(f, filter, recurse)); } //for } //if return files; }