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


Java PatternFilenameFilter类代码示例

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


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

示例1: copyIDEALicense

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
public static void copyIDEALicense(final String sandboxHome) {
  File sandboxSystemPath = new File(sandboxHome, "system");
  File systemPath = new File(PathManager.getSystemPath());
  File[] runningIdeaLicenses = systemPath.listFiles(new PatternFilenameFilter("idea\\d+\\.key"));
  if (runningIdeaLicenses != null) {
    for (File license : runningIdeaLicenses) {
      File devIdeaLicense = new File(sandboxSystemPath, license.getName());
      if (!devIdeaLicense.exists()) {
        try {
          FileUtil.copy(license, devIdeaLicense);
        }
        catch (IOException e) {
          LOG.error(e);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:IdeaLicenseHelper.java

示例2: getExampleTurtleFileNames

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/**
 * Method to get file names from the util package
 * 
 * @return File names as List<>
 */
public static List<String> getExampleTurtleFileNames () { 
    
    List<String> fileNames = new ArrayList();    
    URL fdpFileURL = ExampleTurtleFiles.class.getResource(
            EXAMPLE_FDP_METADATA_FILE);
    String sourceFileURI = fdpFileURL.getPath();
    sourceFileURI = sourceFileURI.replace(EXAMPLE_FDP_METADATA_FILE, "");
    // Matches only turtle files
    Pattern pattern = Pattern.compile("^.*.ttl");    
    FilenameFilter filterByExtension = new PatternFilenameFilter(pattern);
    File dir = new File(sourceFileURI);
    File[] files = dir.listFiles(filterByExtension);  
    for (File file: files) {
        fileNames.add(file.getName());
    }
    LOGGER.info("Turtle files in util packaage " + fileNames.toString());
    return fileNames;
}
 
开发者ID:DTL-FAIRData,项目名称:ODEX-FAIRDataPoint,代码行数:24,代码来源:ExampleTurtleFiles.java

示例3: signalEnd

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
@Override
@Async
public void signalEnd(final List<RecorderInfo> recorders, final File workingDir) {
	// let's merge the results
	String fileName = recorders.get(0).getOutputFile().getName();
	
	int i = 1;
	File[] genDirs = workingDir.listFiles(new PatternFilenameFilter(".*gen-\\d+"));
	for (File genDir : genDirs) {
		File file = new File(genDir, fileName);
		try {
			Files.copy(file, new File(fileName + ".part" + i++));
		} catch (IOException e) {
			log.error("Could not copy '" + file.getName() + "' to '" + fileName + ".part" + i , e);
		}
		
	}
	
	ResultFileMerger merger = new ResultFileMerger();
	merger.merge(recorders, workingDir);
	
	context.publishEvent(new ClusterMain.ExperimentEndedEvent(this));
	
}
 
开发者ID:crisis-economics,项目名称:CRISIS,代码行数:25,代码来源:ExperimentEndHandler.java

示例4: runScriptsInDirectory

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/**
 * Run scripts in the directory if the file names match the pattern. This
 * will try to run all scripts, even if some fail. Each script runs
 * independently in its own environment.
 * 
 * TODO: Add boolean recursive option
 *
 * @param map
 *            initial environment
 * @param directoryName
 *            directory where scripts should be found
 * @param pattern
 *            Only run scripts whose name match this file name pattern.
 */
public static void runScriptsInDirectory(Map<String, Object> map,
        String directoryName, final String pattern) {
    File dir = new File(directoryName);
    ArrayList<String> fileNames = new ArrayList<String>();
    FilenameFilter filter = pattern == null ? unravlScriptFile
            : new PatternFilenameFilter(pattern);
    if (dir.exists() && dir.isDirectory()) {
        File files[] = dir.listFiles(filter);
        for (File file : files) {
            if (!file.isDirectory())
                fileNames.add(file.getAbsolutePath());
        }
        int count = runScriptFiles(map,
                fileNames.toArray(new String[fileNames.size()]));
        System.out.println(String.format("Ran %s scripts in %s%s", count,
                directoryName, pattern == null ? "" : " matching pattern "
                        + pattern));
    } else {
        throw new AssertionError(String.format(
                "Warning: directory %s does not exist.", dir));
    }
}
 
开发者ID:sassoftware,项目名称:unravl,代码行数:37,代码来源:JUnitWrapper.java

示例5: tryScriptsInDirectory

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
public static void tryScriptsInDirectory(UnRAVLRuntime runtime,
        Map<String, Object> env, String directoryName, String pattern) {
    File dir = new File(directoryName);
    ArrayList<String> fileNames = new ArrayList<String>();
    FilenameFilter filter = pattern == null ? unravlScriptFile
            : new PatternFilenameFilter(pattern);
    if (dir.exists() && dir.isDirectory()) {
        File files[] = dir.listFiles(filter);
        for (File file : files) {
            if (!file.isDirectory())
                fileNames.add(file.getAbsolutePath());
        }
        int count = JUnitWrapper.tryScriptFiles(
                runtime == null ? new UnRAVLRuntime(env) : runtime,
                fileNames.toArray(new String[fileNames.size()]));
        System.out.println(String.format("Tried %s scripts in %s%s", count,
                directoryName, pattern == null ? "" : " matching pattern "
                        + pattern));
    } else {
        throw new AssertionError(String.format(
                "Warning: directory %s does not exist.", dir));
    }
}
 
开发者ID:sassoftware,项目名称:unravl,代码行数:24,代码来源:JUnitWrapper.java

示例6: SeqVectorReader

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
public SeqVectorReader(String dirName, String filterPattern, boolean shuffle) throws IOException{
	dir = new File(dirName);
	listFiles = dir.listFiles(new PatternFilenameFilter(dir.getName() + filterPattern));
	if (shuffle){
		shuffle(listFiles);
		
		System.out.println(Arrays.toString(listFiles));
	}else {
		//sort by blockid
	}
	if (listFiles == null || listFiles.length == 0){
		throw new RuntimeException("blocks not found!");
	}
	msgpack = new MessagePack();
	unpacker = msgpack.createUnpacker(new BufferedInputStream(new FileInputStream(listFiles[blockIt]),1024 * 1024 * 2));
	stat = DataSetInfo.load(new File(dirName + "/" + dir.getName()  + ".sta"));
	vt = VectorType.valueOf(stat.getProperty("vectorType"));
}
 
开发者ID:lgnlgn,项目名称:feluca,代码行数:19,代码来源:SeqVectorReader.java

示例7: MultiVectorReader

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
public MultiVectorReader(String dirName, int... parts) throws IOException{
	
	if (parts == null){ //all
		File dir = new File(dirName);
		File[] listFiles = dir.listFiles(new PatternFilenameFilter(dir.getName() + "\\.v\\.\\d+\\.dat"));
		parts = new int[listFiles.length];
		for(int i = 0 ; i < listFiles.length; i++){
			String blockPart = listFiles[i].getName().split("\\.v\\.")[1];
			int blockId = Integer.parseInt(blockPart.substring(0, blockPart.indexOf(".dat")));
			parts[i] = blockId;
		}
	}else{
		this.parts = parts;
	}
	readers = new ArrayList<SeqVectorReader>(parts.length);
	currentVectors = new ArrayList<Vector>(parts.length);
	for(int i = 0 ; i < parts.length; i++){
		readers.add(new SeqVectorReader(dirName, "\\.v\\." + parts[i] +"\\.dat"));
	}
	vt = readers.get(0).getVectorType();
	dir = readers.get(0).getDataDir();
}
 
开发者ID:lgnlgn,项目名称:feluca,代码行数:23,代码来源:MultiVectorReader.java

示例8: list

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Iterable<StorageMetadata> list() {
    final Set<StorageMetadata> metadatas = Sets.newHashSet();
    final File[] files = baseStorageDir().listFiles(new PatternFilenameFilter(".*\\.unc"));
    if (files != null) {
        for (final File file : files) {
            final StorageMetadata sm = new StorageMetadata();
            sm.setCreationTimestamp(new Date(file.lastModified()));
            sm.setHandle(handleFromFile(file));
            sm.setUncompressedSize(file.length());
            metadatas.add(sm);
        }
    }
    return metadatas;
}
 
开发者ID:NCIP,项目名称:caarray,代码行数:19,代码来源:FilesystemDataStorage.java

示例9: getPlayer

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
private String getPlayer(String check)
{
	synchronized (players)
	{
		if (players.isEmpty())
		{
			File worldFolder = ess.getServer().getWorlds().get(0).getWorldFolder();
			File playersFolder = new File(worldFolder, "players");
			for (String filename : playersFolder.list(new PatternFilenameFilter(".+\\.dat")))
			{
				String name = filename.substring(0, filename.length() - 4).toLowerCase(Locale.ENGLISH);
				String sanitizedName = Util.sanitizeFileName(name);
				String mapName = players.get(sanitizedName);
				if (mapName != null && !mapName.equals(name))
				{
					players.put(sanitizedName, BROKENNAME);
				}
				else
				{
					players.put(sanitizedName, name);
				}
			}
		}
	}
	return players.get(check);
}
 
开发者ID:Curtis3321,项目名称:Essentials,代码行数:27,代码来源:UpdateUserFiles.java

示例10: LoadRunner

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/**
 * @param client recommender to load
 * @param dataDirectory a directory containing data files from which user and item IDs should be read
 * @param steps number of load steps to run
 */
public LoadRunner(MyrrixRecommender client, File dataDirectory, int steps) throws IOException {
  Preconditions.checkNotNull(client);
  Preconditions.checkNotNull(dataDirectory);
  Preconditions.checkArgument(steps > 0);  
  
  log.info("Reading IDs...");    
  FastIDSet userIDsSet = new FastIDSet();
  FastIDSet itemIDsSet = new FastIDSet();
  Splitter comma = Splitter.on(',');
  for (File f : dataDirectory.listFiles(new PatternFilenameFilter(".+\\.csv(\\.(zip|gz))?"))) {
    for (CharSequence line : new FileLineIterable(f)) {
      Iterator<String> it = comma.split(line).iterator();
      userIDsSet.add(Long.parseLong(it.next()));
      itemIDsSet.add(Long.parseLong(it.next()));
    }
  }
  
  this.client = client;    
  this.uniqueUserIDs = userIDsSet.toArray();
  this.uniqueItemIDs = itemIDsSet.toArray();
  this.steps = steps;
}
 
开发者ID:myrrix,项目名称:myrrix-recommender,代码行数:28,代码来源:LoadRunner.java

示例11: generateClasspath

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/** Generates classpath string using paths of all plugins available and the Bukkit JAR */
private String generateClasspath()
{
    File   pluginDir = new File("plugins/").getAbsoluteFile();
    File[] plugins   = pluginDir.listFiles( new PatternFilenameFilter(".+\\.jar") );
    String classpath = BUKKIT_JAR;

    for (File plugin : plugins)
        classpath += ";" + plugin.getAbsolutePath();

    return classpath;
}
 
开发者ID:Gamealition,项目名称:SoftPlugin,代码行数:13,代码来源:Compiler.java

示例12: afterPropertiesSet

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws IOException {
	File[] jsonfiles = defDir.listFiles(new PatternFilenameFilter(".*\\.json$"));
	configure(jsonfiles, jsonObjectMapper);
	File[] yamlfiles = defDir.listFiles(new PatternFilenameFilter(".*\\.yaml$"));
	configure(yamlfiles, yamlObjectMapper);
}
 
开发者ID:agwlvssainokuni,项目名称:springapp,代码行数:8,代码来源:StubConfigLoader.java

示例13: doPartition

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
void doPartition(VectorReader reader, int shards, String suffix) throws IOException{
	assert (isPowerOfTwo(shards) == true);
	File[] dats = reader.getDataDir().listFiles(new PatternFilenameFilter(".*\\.v\\.\\d+\\.dat"));
	for(File dat : dats){
		System.out.print(dat.getName() + ";");
		dat.delete();
	}
	String dataName = reader.getDataDir().getName();
	HashPartitioner partitioner = new HashPartitioner(shards);
	String blockPathTemplate = reader.getDataDir().getAbsolutePath() + "/" + dataName + ".v.%d.dat" + suffix;

	ArrayList<Packer> packers = new ArrayList<Packer>(shards);
	MessagePack messagePack = new MessagePack();
	for(int i = 0 ; i < shards;i++){ //output
		packers.add(messagePack.createPacker(
				new BufferedOutputStream(new FileOutputStream(String.format(blockPathTemplate, i)), 1024 * 1024 * 2)));
	}

	int count = 0;
	for(Vector v = reader.getNextVector(); v!= null; v = reader.getNextVector()){
		List<Vector> divided = v.divideByFeature(partitioner); 
		for(int i = 0 ; i < divided.size(); i++){
			packers.get(i).write(true);
			divided.get(i).pack(packers.get(i));
		}
		count ++;
		if (count % 2000 == 0){
			for(int i = 0 ; i < packers.size(); i++){
				packers.get(i).flush();
			}
			System.out.print("*");
		}
	}
	for(int i = 0 ; i < packers.size(); i++){
		packers.get(i).write(false).close();
	}
}
 
开发者ID:lgnlgn,项目名称:feluca,代码行数:38,代码来源:VectorPartitioner.java

示例14: getAvailableSettingsFiles

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
/**
 * @return the availableSettingsFiles
 */
public Set<String> getAvailableSettingsFiles() {
	if (availableSettingsFiles == null) {
		String[] list = settingsDir.list(new PatternFilenameFilter(".*\\.xml"));
		if (list == null) {
			availableSettingsFiles = newTreeSet();
		} else {
			availableSettingsFiles = newTreeSet(asList(list));
		}
	}
	return ImmutableSet.copyOf(availableSettingsFiles);
}
 
开发者ID:mgm-tp,项目名称:perfload-loadprofiles,代码行数:15,代码来源:ConfigController.java

示例15: deleteOldExtractors

import com.google.common.io.PatternFilenameFilter; //导入依赖的package包/类
private void deleteOldExtractors(File dir, String classSuffix) {
	File[] files = dir.listFiles(new PatternFilenameFilter(".*" + classSuffix + ".java"));
	if (files != null)
		for (File e : files)
			e.delete();
	dir.mkdirs();
}
 
开发者ID:pescuma,项目名称:buildhealth,代码行数:8,代码来源:WarningsExtractorGenerator.java


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