Java 类java.io.FileFilter 实例源码

项目:convertigo-engine    文件:ProjectUtils.java   
public static void copyIndexFile(String projectName) throws Exception {
    String projectRoot = Engine.PROJECTS_PATH + '/' +  projectName;
    String templateBase = Engine.TEMPLATES_PATH + "/base";
    File indexPage = new File(projectRoot + "/index.html");
    if (!indexPage.exists()) {
        if (new File(projectRoot + "/sna.xsl").exists()) { /** webization javelin */
            if (new File(projectRoot + "/templates/status.xsl").exists()) { /** not DKU / DKU */
                FileUtils.copyFile(new File(templateBase + "/index_javelin.html"), indexPage);
            } else {
                FileUtils.copyFile(new File(templateBase + "/index_javelinDKU.html"), indexPage);
            }
        } else {
            FileFilter fileFilterNoSVN = new FileFilter() {
                public boolean accept(File pathname) {
                    String name = pathname.getName();
                    return !name.equals(".svn") || !name.equals("CVS") || !name.equals("node_modules");
                }
            };
            FileUtils.copyFile(new File(templateBase + "/index.html"), indexPage);
            FileUtils.copyDirectory(new File(templateBase + "/js"), new File(projectRoot + "/js"), fileFilterNoSVN);
            FileUtils.copyDirectory(new File(templateBase + "/css"), new File(projectRoot + "/css"), fileFilterNoSVN);
        }
    }
}
项目:lams    文件:FileUtils.java   
/**
 * Finds files within a given directory (and optionally its
 * subdirectories). All files found are filtered by an IOFileFilter.
 *
 * @param files the collection of files found.
 * @param directory the directory to search in.
 * @param filter the filter to apply to files and directories.
 * @param includeSubDirectories indicates if will include the subdirectories themselves
 */
private static void innerListFiles(Collection<File> files, File directory,
        IOFileFilter filter, boolean includeSubDirectories) {
    File[] found = directory.listFiles((FileFilter) filter);

    if (found != null) {
        for (File file : found) {
            if (file.isDirectory()) {
                if (includeSubDirectories) {
                    files.add(file);
                }
                innerListFiles(files, file, filter, includeSubDirectories);
            } else {
                files.add(file);
            }
        }
    }
}
项目:Equella    文件:WizardServiceImpl.java   
@Override
public FileNode getFileTree(WizardState state, String path)
{
    StagingFile stagingFile = new StagingFile(state.getStagingId());
    FileFilter filter = new FileFilter()
    {
        @Override
        public boolean accept(File pathname)
        {
            String name = pathname.getName();
            return !pathname.isDirectory() || name.equals("_zips") || name.charAt(0) != '_';
        }
    };

    try
    {
        FileEntry fileTree = fileSystemService.enumerateTree(stagingFile, path, filter);
        FileNode root = recurseTree(fileTree);
        root.setFullpath(path);
        return root;
    }
    catch( IOException ex )
    {
        throw new RuntimeApplicationException("Error enumerating file tree", ex);
    }
}
项目:sentimental-analyzer    文件:BasicInformationCollector.java   
@Override
public void fire() {
    // get total document count for computing TF-IDF
    int totalDocCount = 0;
    for(String label : context.getFDMetadata().getInputRootDir().list()) {
        context.getVectorMetadata().addLabel(label);
        LOG.info("Add label: label=" + label);
        File labelDir = new File(context.getFDMetadata().getInputRootDir(), label);
        File[] files = labelDir.listFiles(new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                return pathname.getAbsolutePath().endsWith(context.getFDMetadata().getFileExtensionName());
            }
        });
        context.getVectorMetadata().putLabelledTotalDocCount(label, files.length);
        LOG.info("Put document count: label= " + label + ", docCount=" + files.length);
        totalDocCount += files.length;
    }
    LOG.info("Total documents: totalCount= " + totalDocCount);
    context.getVectorMetadata().setTotalDocCount(totalDocCount);
}
项目:openrasp    文件:JsPluginManager.java   
/**
 * 更新插件引擎
 * <p>
 * 检测脚本变化时更新
 * <p>
 * 当新插件引擎初始化成功之后再替换旧插件引擎
 *
 * @throws Exception
 */
private synchronized static void updatePlugin() throws Exception {
    // 清空 algorithm.config 配置
    Config.getConfig().setAlgorithmConfig("{}");
    boolean oldValue = HookHandler.enableHook.getAndSet(false);
    File pluginDir = new File(Config.getConfig().getScriptDirectory());
    LOGGER.debug("checker directory: " + pluginDir.getAbsolutePath());
    if (!pluginDir.isDirectory()) {
        pluginDir.mkdir();
    }
    File[] pluginFiles = pluginDir.listFiles((FileFilter) FileFilterUtils.suffixFileFilter(".js"));
    List<CheckScript> scripts = new LinkedList<CheckScript>();
    for (File file : pluginFiles) {
        try {
            scripts.add(new CheckScript(file));
        } catch (Exception e) {
            LOGGER.error("", e);
        }
    }

    JSContextFactory.setCheckScriptList(scripts);

    HookHandler.enableHook.set(oldValue);
}
项目:GitHub    文件:StrUtils.java   
public static int getNumCores() {
    class CpuFilter implements FileFilter {
        @Override
        public boolean accept(File pathname) {
            if (Pattern.matches("cpu[0-9]", pathname.getName())) {
                return true;
            }
            return false;
        }
    }
    try {
        File dir = new File("/sys/devices/system/cpu/");
        File[] files = dir.listFiles(new CpuFilter());
        return files.length;
    } catch (Exception e) {
        return 1;
    }
}
项目:KotlinStudy    文件:FaceUtil.java   
public static int getNumCores() {
    class CpuFilter implements FileFilter {
        @Override
        public boolean accept(File pathname) {
            if(Pattern.matches("cpu[0-9]", pathname.getName())) {
                return true;
            }
            return false;
        }      
    }
    try {
        File dir = new File("/sys/devices/system/cpu/");
        File[] files = dir.listFiles(new CpuFilter());
        return files.length;
    } catch(Exception e) {
        e.printStackTrace();
        return 1;
    }
}
项目:s-store    文件:SnapshotDelete.java   
private final List<File> retrieveRelevantFiles(File f, final String nonce) {
    assert(f.isDirectory());
    assert(f.canRead());
    assert(f.canWrite());
    final String digestName =
        SnapshotUtil.constructDigestFilenameForNonce(nonce.substring(0, nonce.lastIndexOf('-')));
    return java.util.Arrays.asList(f.listFiles(new FileFilter() {

        @Override
        public boolean accept(File pathname) {
            if (pathname.isDirectory()) {
                return false;
            }

            if (!pathname.getName().endsWith(".vpt") && !pathname.getName().endsWith(".digest")) {
                return false;
            }

            if (pathname.getName().startsWith(nonce) || pathname.getName().equals(digestName)) {
                return true;
            }
            return false;
        }
    }));
}
项目:incubator-netbeans    文件:NbModuleProviderImpl.java   
/**
 * Returns possibly cached list of filesystems representing the XML layers of the supplied platform module JARs.
 * If cache is not ready yet, this call blocks until the cache is created.
 * Layer filesystems are already ordered to handle masked ("_hidden") files correctly.
 * @param platformJars
 * @return List of read-only layer filesystems
 * @throws java.io.IOException
 */
private Collection<FileSystem> getCachedLayers(File rootDir, final Set<File> platformJars) throws IOException {
    if (rootDir == null) {
        return Collections.emptySet();
    }
    File[] clusters = rootDir.listFiles(new FileFilter() {
        @Override public boolean accept(File pathname) {
            return ClusterUtils.isValidCluster(pathname);
        }
    });
    Collection<FileSystem> cache = PlatformLayersCacheManager.getCache(clusters, new FileFilter() {
        @Override public boolean accept(File jar) {
            return platformJars.contains(jar);
        }
    });
    return cache;
}
项目:Cognizant-Intelligent-Test-Scripter    文件:HarCompareHandler.java   
static Object getHars(File p, String page) {
    JSONArray dataset = new JSONArray();
    try {
        File[] list = p.listFiles(new FileFilter() {
            @Override
            public boolean accept(File file) {
                return file.getName().endsWith(".har");
            }
        });
        if (list != null) {
            for (File f : list) {
                JSONObject har = new JSONObject();
                har.put("name", f.getName().substring(0, f.getName().length() - 4));
                har.put("loc", f.getName());
                har.put("pageName", page);
                dataset.add(har);
            }
        }
    } catch (Exception ex) {
        LOG.log(Level.WARNING, "Error while reading report history", ex);
    }

    return dataset;
}
项目:incubator-netbeans    文件:PlatformLayersCacheManagerTest.java   
public void testGetCache() throws Exception {
    Collection<FileSystem> cache = PlatformLayersCacheManager.getCache(clusters, new FileFilter() {

        public boolean accept(File pathname) {
            return jarNames.contains(pathname.getName());
        }
    });
    assertNotNull(cache);
    assertEquals("3 of 4 cached JAR-s have layer.xml", 3, cache.size());
    assertNotNull("Pending storing cache to userdir", PlatformLayersCacheManager.storeTask);
    assertTrue("Cache successfully stored to disk", PlatformLayersCacheManager.storeTask.waitFinished(10000));
    assertTrue("Cache exists on disk", (new File(cacheDir, "index.ser")).exists());
    assertEquals("JAR-s from two different clusters", 2,
            cacheDir.list(new FilenameFilter() {

        public boolean accept(File dir, String name) {
            return name.startsWith("cache");
        }
    }).length);
}
项目:incubator-netbeans    文件:UninstallUtils.java   
/**
 * Returns list of clusters
 *
 * @return list of clusters
 */
private static Set<File> getClustersRoots() {
    if (clustersRoots == null) {
        File installationLoc = getInstallationLocation();

        if (installationLoc != null && installationLoc.exists()) {
            FileFilter onlyDirFilter = new FileFilter() {
                @Override
                public boolean accept(File file) {
                    return file.isDirectory();
                }
            };
            clustersRoots = new HashSet<File>(Arrays.asList(installationLoc.listFiles(onlyDirFilter)));
        } else {
            clustersRoots = Collections.EMPTY_SET;
        }
    }

    return clustersRoots;
}
项目:incubator-netbeans    文件:CopyIcons.java   
private void scanForProjectDirs(File fl) {
    if (depth > userDepth) return;
    //if (isProjectDir(fl)) {
    //    projectDirList.add(fl);
    //}
    File allFiles[] = fl.listFiles(new FileFilter() {
        public boolean accept(File pathname) {
            if (pathname.isDirectory()) {
                return true;
            }
            return false;
        }
    });
    depth++;
    for (File f : allFiles) {
        if (isProjectDir(f)) {
            // here could be some project exclusion logic
            projectDirList.add(f);
            log(f.toString(), Project.MSG_VERBOSE);
            scanForProjectDirs(f);
        } else {
            scanForProjectDirs(f);
        }
    }
    depth--;
}
项目:nifi-android-s2s    文件:ListFileCollector.java   
@Override
public Iterable<DataPacket> getDataPackets() {
    long maxLastModified = System.currentTimeMillis() - 1;
    List<DataPacket> dataPackets = new ArrayList<>();
    FileFilter fileFilter;
    if (filterModified) {
        // Filter out any files not modified in window
        ParcelableFileFilter modifiedCompoundFilter = new OrFileFilter(new DirectoryFileFilter(), new LastModifiedFileFilter(minModifiedTime, maxLastModified));
        fileFilter = new AndFileFilter(modifiedCompoundFilter, this.fileFilter);
    } else {
        fileFilter = this.fileFilter;
    }
    listRecursive(baseDir, fileFilter, dataPackets);
    minModifiedTime = maxLastModified + 1;
    return dataPackets;
}
项目:incubator-netbeans    文件:FileUtilAddRecursiveListenerFilterTest.java   
public void testAddListenerGetsFiveCallbacks() throws IOException {
    class AtMostFive implements FileFilter {
        @Override
        public boolean accept(File pathname) {
            assertTrue("It is folder", pathname.isDirectory());
            int number = Integer.parseInt(pathname.getName());
            return number <= 5;
        }

    }

    FileUtil.addRecursiveListener(this, getWorkDir(), new AtMostFive(), null);

    File fifthChild = new File(new File(getWorkDir(), "5"), "new.5.txt");
    assertTrue(fifthChild.createNewFile());
    FileUtil.refreshFor(getWorkDir());
    assertEquals("One event delivered: " + events, 1, events.size());

    File seventhChild = new File(new File(getWorkDir(), "7"), "new.7.txt");
    assertTrue(seventhChild.createNewFile());
    FileUtil.refreshFor(getWorkDir());
    assertEquals("No other even delivered: " + events, 1, events.size());
}
项目:incubator-netbeans    文件:ProvidedExtensionsTest.java   
@Override
public ProvidedExtensions.DeleteHandler getDeleteHandler(File f) {
    return (!isImplsDeleteRetVal()) ? null : new ProvidedExtensions.DeleteHandler(){
        final Set s = new HashSet();
        @Override
        public boolean delete(File file) {
            if (file.isDirectory()) {
                File[] childs = file.listFiles(new FileFilter() {
                    public boolean accept(File pathname) {
                        boolean accepted = pathname.isFile();
                        if (!accepted && pathname.isDirectory()) {
                            accepted = !s.contains(pathname);
                            if (!s.contains(pathname)) {
                                s.add(pathname);
                            }
                        } 
                        return accepted;
                    }
                });
                return childs.length == 0;
            }
            return file.delete();
        }                
    };
}
项目:WithYou    文件:FaceUtil.java   
public static int getNumCores() {
    class CpuFilter implements FileFilter {
        @Override
        public boolean accept(File pathname) {
            if(Pattern.matches("cpu[0-9]", pathname.getName())) {
                return true;
            }
            return false;
        }      
    }
    try {
        File dir = new File("/sys/devices/system/cpu/");
        File[] files = dir.listFiles(new CpuFilter());
        return files.length;
    } catch(Exception e) {
        e.printStackTrace();
        return 1;
    }
}
项目:Backmemed    文件:FolderResourcePack.java   
public Set<String> getResourceDomains()
{
    Set<String> set = Sets.<String>newHashSet();
    File file1 = new File(this.resourcePackFile, "assets/");

    if (file1.isDirectory())
    {
        for (File file2 : file1.listFiles((FileFilter)DirectoryFileFilter.DIRECTORY))
        {
            String s = getRelativeName(file1, file2);

            if (s.equals(s.toLowerCase(java.util.Locale.ROOT)))
            {
                set.add(s.substring(0, s.length() - 1));
            }
            else
            {
                this.logNameNotLowercase(s);
            }
        }
    }

    return set;
}
项目:incubator-netbeans    文件:Utils.java   
private static List savedNbProjects(File dir, int depth, Set pTypes) {
    if (depth > SEARCH_DEPTH) {
        return Collections.EMPTY_LIST;
    }
    List sProjects = new ArrayList();
    File subdirs[] = dir.listFiles(new FileFilter() {
        public boolean accept(File f) {
            if (f.isDirectory()) {
                return true;
            }
            return false;
        }
    });
    for (int i = 0; i < subdirs.length; i++) {
        ProjectType pt = getNbProjectType(subdirs[i]);
        if (pt != null) {
            SavedProjects.OneProject sp = new SavedProjects.OneProject(subdirs[i]);
            sProjects.add(sp);
            pTypes.add(pt);
        }
        sProjects.addAll(savedNbProjects(subdirs[i], depth + 1, pTypes));
    }
    return sProjects;
}
项目:alvisnlp    文件:I2B2Reader.java   
@Override
public void process(ProcessingContext<Corpus> ctx, Corpus corpus) throws ModuleException {
    try {
        FileFilter filter = new PatternFileFilter(Pattern.compile("\\.txt$"), false, false);
        File[] txtFiles = textDir.listFiles(filter);
        for (File f : txtFiles) {
            Map<TokenRef,Annotation> tokens = readText(corpus, f);
            if (conceptsDir != null) {
                readConcepts(corpus, f, tokens);
                if (assertionsDir != null) {
                    readAssertions(corpus, f, tokens);
                }
                if (relationsDir != null) {
                    readRelations(corpus, f, tokens);
                }
            }
        }
    }
    catch (IOException e) {
        rethrow(e);
    }
}
项目:music-player    文件:FileUtils.java   
public static List<Song> musicFiles(File dir) {
    List<Song> songs = new ArrayList<>();
    if (dir != null && dir.isDirectory()) {
        final File[] files = dir.listFiles(new FileFilter() {
            @Override
            public boolean accept(File item) {
                return item.isFile() && isMusic(item);
            }
        });
        for (File file : files) {
            Song song = fileToMusic(file);
            if (song != null) {
                songs.add(song);
            }
        }
    }
    if (songs.size() > 1) {
        Collections.sort(songs, new Comparator<Song>() {
            @Override
            public int compare(Song left, Song right) {
                return left.getTitle().compareTo(right.getTitle());
            }
        });
    }
    return songs;
}
项目:afp-api-client    文件:AFPDataGrabber.java   
public static Collection<File> getValidReplayDirectories(File root) {
    Collection<File> res = new ArrayList<>();
    if (isValidReplayDirectory(root)) {
        res.add(root);
    } else {
        if (root.exists() && root.isDirectory()) {
            for (File sub : root.listFiles(new FileFilter() {

                @Override
                public boolean accept(File pathname) {
                    return pathname.isDirectory();
                }
            })) {
                res.addAll(getValidReplayDirectories(sub));
            }
        }
    }
    return res;
}
项目:marathonv5    文件:UserDirScanner.java   
private static List<NBInstallation> allNBInstallations(File nbUserHome) {
    File files[] = nbUserHome.listFiles(new FileFilter() {
        public boolean accept(File f) {
            return f.isDirectory();
        }
    });
    List<NBInstallation> list = new ArrayList<NBInstallation>();
    // files might be null here, e.g. if there is no .netbeans folder
    if (files != null) {
        for (File file : files) {
            // creating NB installation is based on userdir
            NBInstallation nbi = new NBInstallation(file);
            if (nbi.isValid()) {
                list.add(nbi);
            }
        }
    }
    return list;
}
项目:marathonv5    文件:ModuleList.java   
private Module loadModulesFromFS(File file, Module parent) {
    if (file.isDirectory()) {
        Module module = new Module(getModuleName(file), parent);
        File[] files = file.listFiles(new FileFilter() {
            @Override public boolean accept(File pathname) {
                if (pathname.getName().startsWith(".")) {
                    return false;
                }
                return pathname.isDirectory() || pathname.getName().endsWith(".rb");
            }
        });
        if (files != null) {
            for (File child : files) {
                Module m = loadModulesFromFS(child, module);
                if (m != null) {
                    module.addChild(m);
                }
            }
        }
        if (module.getChildren().size() > 0) {
            return module;
        }
        return null;
    }
    return loadFunctionsFromFile(file, parent);
}
项目:javaps-geotools-backend    文件:IOUtils.java   
/**
 * Delete the given files and all the files with the same name but different
 * extension. If some file is <code>null</code> just doesn't process it and
 * continue to the next element of the array
 *
 * @param files
 *            the files to delete
 */
private static void delete(File... files) {
    for (File file : files) {
        if (file != null) {
            final String baseName = file.getName().substring(0,
                    file.getName().lastIndexOf("."));
            File[] list = file.getAbsoluteFile().getParentFile().listFiles(
                    new FileFilter() {
                        @Override
                        public boolean accept(File pathname) {
                            return pathname.getName().startsWith(baseName);
                        }
                    });
            for (File f : list) {
                f.deleteOnExit();
            }

            file.deleteOnExit();
        }
    }
}
项目:marathonv5    文件:UserDirScanner.java   
private static List<NBInstallation> allNBInstallations(File nbUserHome) {
    File files[] = nbUserHome.listFiles(new FileFilter() {
        public boolean accept(File f) {
            return f.isDirectory();
        }
    });
    List<NBInstallation> list = new ArrayList<NBInstallation>();
    // files might be null here, e.g. if there is no .netbeans folder
    if (files != null) {
        for (File file : files) {
            // creating NB installation is based on userdir
            NBInstallation nbi = new NBInstallation(file);
            if (nbi.isValid()) {
                list.add(nbi);
            }
        }
    }
    return list;
}
项目:sstore-soft    文件:SnapshotDelete.java   
private final List<File> retrieveRelevantFiles(File f, final String nonce) {
    assert(f.isDirectory());
    assert(f.canRead());
    assert(f.canWrite());
    final String digestName =
        SnapshotUtil.constructDigestFilenameForNonce(nonce.substring(0, nonce.lastIndexOf('-')));
    return java.util.Arrays.asList(f.listFiles(new FileFilter() {

        @Override
        public boolean accept(File pathname) {
            if (pathname.isDirectory()) {
                return false;
            }

            if (!pathname.getName().endsWith(".vpt") && !pathname.getName().endsWith(".digest")) {
                return false;
            }

            if (pathname.getName().startsWith(nonce) || pathname.getName().equals(digestName)) {
                return true;
            }
            return false;
        }
    }));
}
项目:uavstack    文件:ReliableTaildirEventReader.java   
private List<File> getMatchFiles(File parentDir, final Pattern fileNamePattern) {

        FileFilter filter = new FileFilter() {

            @Override
            public boolean accept(File f) {

                String fileName = f.getName();
                if (f.isDirectory() || !fileNamePattern.matcher(fileName).matches()) {
                    return false;
                }
                return true;
            }
        };
        File[] files = parentDir.listFiles(filter);
        ArrayList<File> result = (files == null) ? Lists.<File> newArrayList() : Lists.newArrayList(files);
        Collections.sort(result, new TailFile.CompareByLastModifiedTime());
        return result;
    }
项目:Accessibility    文件:FileUtils.java   
/**
 * 实现listFiles功能,遍历过程中进行锁判斿
 */
private File[] listFiles(File f, FileFilter filter) {
    if (f == null) {
        return null;
    }

    File[] files = f.listFiles();
    if (filter == null || files == null) {
        return files;
    }

    List<File> result = new ArrayList<File>(files.length);
    for (File file : files) {
        if (mLock.isExit()) {
            break;
        } else {
            mLock.callWait();
        }
        if (filter.accept(file)) {
            result.add(file);
        }
    }
    return result.toArray(new File[result.size()]);
}
项目:directory-ldap-api    文件:OsgiUtils.java   
/**
 * All the packages that are exported from all bundles found on the system
 * classpath. The provided filter if not null is used to prune classpath
 * elements. Any uses terms found are stripped from the bundles.
 *
 * @param filter The filter to use on the files
 * @param pkgs The set of packages to use
 * @return All the exported packages of all bundles on the classpath.
 */
public static Set<String> getAllBundleExports( FileFilter filter, Set<String> pkgs )
{
    if ( pkgs == null )
    {
        pkgs = new HashSet<>();
    }

    Set<File> candidates = getClasspathCandidates( filter );

    for ( File candidate : candidates )
    {
        String exports = getBundleExports( candidate );

        if ( exports == null )
        {
            LOG.debug( "No export found for candidate: {}", candidate );
            continue;
        }

        LOG.debug( "Processing exports for candidate: {}\n\n{}\n", candidate, exports );
        splitIntoPackages( exports, pkgs );
    }

    return pkgs;
}
项目:r8    文件:MultiDexExtractor.java   
/**
 * This removes any files that do not have the correct prefix.
 */
private static void prepareDexDir(File dexDir, final String extractedFilePrefix)
        throws IOException {
    dexDir.mkdir();
    if (!dexDir.isDirectory()) {
        throw new IOException("Failed to create dex directory " + dexDir.getPath());
    }

    // Clean possible old files
    FileFilter filter = new FileFilter() {

        @Override
        public boolean accept(File pathname) {
            return !pathname.getName().startsWith(extractedFilePrefix);
        }
    };
    File[] files = dexDir.listFiles(filter);
    if (files == null) {
        return;
    }
    for (File oldFile : files) {
        if (!oldFile.delete()) {
        } else {
        }
    }
}
项目:mpeg-audio-streams    文件:MP3TestFiles.java   
/**
 * iterateOverTestFiles.
 * @param fileHandler {@link FileHandler}
 * @param mp3TestFileDirectory {@link String}
 */
public static void iterateOverTestFiles(final FileHandler fileHandler, final String mp3TestFileDirectory) {
    final File[] files = new File(mp3TestFileDirectory).listFiles(new FileFilter() {
        @Override
        public boolean accept(final File pathname) {
            return pathname.isFile() && pathname.canRead()
                    && pathname.getName().toLowerCase().endsWith(MP3TestFiles.MP3_SUFFIX);
        }
    });
    if (files != null) {
        for (final File file : files) {
            fileHandler.handle(file);
        }
    } else {
        MP3TestFiles.LOG.error("Could not find mp3 test file directory [" + mp3TestFileDirectory //$NON-NLS-1$
                + "]."); //$NON-NLS-1$
    }
}
项目:Hello-Music-droid    文件:FolderLoader.java   
public static List<File> getMediaFiles(File dir, final boolean acceptDirs) {
    ArrayList<File> list = new ArrayList<>();
    list.add(new File(dir, ".."));
    if (dir.isDirectory()) {
        List<File> files = Arrays.asList(dir.listFiles(new FileFilter() {

            @Override
            public boolean accept(File file) {
                if (file.isFile()) {
                    String name = file.getName();
                    return !".nomedia".equals(name) && checkFileExt(name);
                } else if (file.isDirectory()) {
                    return acceptDirs && checkDir(file);
                } else
                    return false;
            }
        }));
        Collections.sort(files, new FilenameComparator());
        Collections.sort(files, new DirFirstComparator());
        list.addAll(files);
    }

    return list;
}
项目:androidtools    文件:AppUtils.java   
/**
 * Get CPU core number
 *
 * @return CPU core number
 */
public static int getNumCores() {
    try {
        File dir = new File("/sys/devices/system/cpu/");
        File[] files = dir.listFiles(new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                if (Pattern.matches("cpu[0-9]", pathname.getName())) {
                    return true;
                }
                return false;
            }
        });
        return files.length;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return 1;
}
项目:BlockCanaryEx    文件:PerformanceUtils.java   
/**
 * Get cpu core number
 *
 * @return int cpu core number
 */
public static int getNumCores() {
    class CpuFilter implements FileFilter {
        @Override
        public boolean accept(File pathname) {
            return Pattern.matches("cpu[0-9]", pathname.getName());
        }
    }

    if (sCoreNum == 0) {
        try {
            // Get directory containing CPU info
            File dir = new File("/sys/devices/system/cpu/");
            // Filter to only list the devices we care about
            File[] files = dir.listFiles(new CpuFilter());
            // Return the number of cores (virtual CPU devices)
            sCoreNum = files.length;
        } catch (Exception e) {
            Log.e(TAG, "getNumCores exception", e);
            sCoreNum = 1;
        }
    }
    return sCoreNum;
}
项目:ModuleFrame    文件:FileUtil.java   
/**
 * 删除目录下所有东西
 *
 * @param dir 目录
 * @return {@code true}: 删除成功<br>{@code false}: 删除失败
 */
public static boolean deleteAllInDir(final File dir) {
    return deleteFilesInDirWithFilter(dir, new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return true;
        }
    });
}
项目:echo    文件:GetFileFromAttribute.java   
private Set<File> performListing(final File directory, final FileFilter filter, final boolean recurseSubdirectories) {
    Path p = directory.toPath();
    if (!Files.isWritable(p) || !Files.isReadable(p)) {
        throw new IllegalStateException("Directory '" + directory + "' does not have sufficient permissions (i.e., not writable and readable)");
    }
    final Set<File> queue = new HashSet<File>();
    if (!directory.exists()) {
        return queue;
    }

    final File[] children = directory.listFiles();
    if (children == null) {
        return queue;
    }

    for (final File child : children) {
        if (child.isDirectory()) {
            if (recurseSubdirectories) {
                queue.addAll(performListing(child, filter, recurseSubdirectories));
            }
        } else if (filter.accept(child)) {
            queue.add(child);
        }
    }

    return queue;
}
项目:Equella    文件:FileSystemServiceImpl.java   
@Override
public FileEntry enumerateTree(FileHandle handle, String path, FileFilter filter)
{
    File rootFile = getFile(handle, path);
    FileEntry root = new FileEntry(rootFile);
    root.setName(FileSystemHelper.decode(rootFile.getName()));
    enumTree(root, rootFile, filter);
    return root;
}
项目:jdk8u-jdk    文件:TestHelper.java   
static FileFilter createFilter(final String extension) {
    return new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            String name = pathname.getName();
            if (name.endsWith(extension)) {
                return true;
            }
            return false;
        }
    };
}
项目:GitHub    文件:Jsonschema2PojoMojo.java   
FileFilter createFileFilter() throws MojoExecutionException {
    try {
        URL urlSource = URLUtil.parseURL(sourceDirectory);
        return new MatchPatternsFileFilter.Builder().addIncludes(includes).addExcludes(excludes).addDefaultExcludes().withSourceDirectory(URLUtil.getFileFromURL(urlSource).getCanonicalPath()).withCaseSensitive(false).build();
    } catch (IOException e) {
        throw new MojoExecutionException("could not create file filter", e);
    }
}