当前位置: 首页>>代码示例>>Java>>正文


Java FileFilter类代码示例

本文整理汇总了Java中java.io.FileFilter的典型用法代码示例。如果您正苦于以下问题:Java FileFilter类的具体用法?Java FileFilter怎么用?Java FileFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileFilter类属于java.io包,在下文中一共展示了FileFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyIndexFile

import java.io.FileFilter; //导入依赖的package包/类
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);
       	}
   	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:25,代码来源:ProjectUtils.java

示例2: savedNbProjects

import java.io.FileFilter; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:Utils.java

示例3: innerListFiles

import java.io.FileFilter; //导入依赖的package包/类
/**
 * 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);
            }
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:FileUtils.java

示例4: getFileTree

import java.io.FileFilter; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:27,代码来源:WizardServiceImpl.java

示例5: fire

import java.io.FileFilter; //导入依赖的package包/类
@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);
}
 
开发者ID:Donkey-Tao,项目名称:sentimental-analyzer,代码行数:22,代码来源:BasicInformationCollector.java

示例6: updatePlugin

import java.io.FileFilter; //导入依赖的package包/类
/**
 * 更新插件引擎
 * <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);
}
 
开发者ID:baidu,项目名称:openrasp,代码行数:33,代码来源:JsPluginManager.java

示例7: getNumCores

import java.io.FileFilter; //导入依赖的package包/类
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;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:StrUtils.java

示例8: getNumCores

import java.io.FileFilter; //导入依赖的package包/类
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;
    }
}
 
开发者ID:SoulEaterVTT,项目名称:KotlinStudy,代码行数:20,代码来源:FaceUtil.java

示例9: retrieveRelevantFiles

import java.io.FileFilter; //导入依赖的package包/类
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;
        }
    }));
}
 
开发者ID:s-store,项目名称:s-store,代码行数:26,代码来源:SnapshotDelete.java

示例10: getCachedLayers

import java.io.FileFilter; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:NbModuleProviderImpl.java

示例11: getHars

import java.io.FileFilter; //导入依赖的package包/类
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;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:25,代码来源:HarCompareHandler.java

示例12: testGetCache

import java.io.FileFilter; //导入依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:PlatformLayersCacheManagerTest.java

示例13: getClustersRoots

import java.io.FileFilter; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:UninstallUtils.java

示例14: scanForProjectDirs

import java.io.FileFilter; //导入依赖的package包/类
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--;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:CopyIcons.java

示例15: getDataPackets

import java.io.FileFilter; //导入依赖的package包/类
@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;
}
 
开发者ID:hortonworks,项目名称:nifi-android-s2s,代码行数:17,代码来源:ListFileCollector.java


注:本文中的java.io.FileFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。