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


Java WildcardFileFilter类代码示例

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


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

示例1: getExecutable

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
private String getExecutable() {
    File supposedExecutable = new File(executableDir + executableName);

    if(supposedExecutable.exists()) {
        return supposedExecutable.getAbsolutePath();
    } else {
        Collection<File> theExecutable = FileUtils.listFiles(new File(executableDir), new WildcardFileFilter(executableName), TrueFileFilter.INSTANCE);

        if(theExecutable != null || theExecutable.size() > 1 || theExecutable.isEmpty()) {
            File newestExecutable = theExecutable.stream().reduce(new File(""),
                    (aFile, newestFile) -> {
                        if(aFile.lastModified() > newestFile.lastModified()) {
                            return aFile;
                        }

                        return newestFile;
                    });

            return newestExecutable.getAbsolutePath();
        } else if(theExecutable.size() == 1) {
            return ((File)CollectionUtils.get(theExecutable, 0)).getAbsolutePath();
        } else {
            throw new RuntimeException("Could not determine executable path");
        }
    }
}
 
开发者ID:corydissinger,项目名称:mtgo-best-bot,代码行数:27,代码来源:ProcessManager.java

示例2: testisFSMValid

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
/**
 * Check if FSM is valid.
 *
 * @throws Exception the exception
 */
@Test
public void testisFSMValid() throws Exception {
  final File directory = new File("target");
  final Collection<File> files = FileUtils.listFiles(directory, new WildcardFileFilter("*.fsm"),
      null);
  final Iterator<File> iterator = files.iterator();
  assertTrue("FSM doesn't contain any files", iterator.hasNext());
  if (iterator.hasNext()) {
    try (final ZipFile _fsmZip = new ZipFile(iterator.next())) {
      final ZipEntry license = _fsmZip.getEntry("LICENSE");
      errors.checkThat("Couldn't find module descriptor (module.xml) in fsm file", license,
          is(notNullValue()));
      final ZipEntry moduleXML = _fsmZip.getEntry(MODULE_DESCRIPTOR);
      errors.checkThat("Couldn't find module descriptor (module.xml) in fsm file", moduleXML,
          is(notNullValue()));
      final ZipEntry consoleLib = _fsmZip.getEntry("lib/console-"
          + pomProperties.getProperty("version") + ".jar");
      errors.checkThat("Couldn't find lib in fsm file", consoleLib, is(notNullValue()));
      final ZipEntry toolbarLib = _fsmZip.getEntry("lib/toolbar-"
          + pomProperties.getProperty("version") + ".jar");
      errors.checkThat("Couldn't find lib in fsm file", toolbarLib, is(notNullValue()));
    }
  }

}
 
开发者ID:zaplatynski,项目名称:second-hand-log,代码行数:31,代码来源:FsmIT.java

示例3: loadConfig

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
@Override
public Collection<T> loadConfig() {
    Collection<T> configData = new ArrayList<>();
    final File configDirectory = new File(configuration.getDataDirectory(), dataDirectory);
    final File[] dataFiles = configDirectory.listFiles((FilenameFilter) new WildcardFileFilter("*.yml"));
    if (dataFiles == null) {
        throw ConfigValidationException.createFileReadError(configDirectory.getAbsolutePath());
    }

    for (File dataFile : dataFiles) {
        T data;
        try {
            data = configurationFactory.build(dataFile);
        } catch (IOException | ConfigurationException e) {
            throw Throwables.propagate(e);
        }
        configData.add(data);

    }
    return configData;
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:22,代码来源:FileBackedConfigDataSource.java

示例4: cleanDatabaseFiles

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
private void cleanDatabaseFiles() {
    final File databaseFile = endPointHealthConfiguration.databaseFile();
    final File parentFile = databaseFile.getParentFile();

    if (parentFile == null || !parentFile.exists()) {
        return;
    }

    FileUtils.listFiles(parentFile,
        new WildcardFileFilter(databaseFile.getName() + "*"), null).forEach(file -> {
            try {
                FileUtils.forceDelete(file);
                LOGGER.info(file + " deleted");
            } catch (final Exception e) {
                throw new EndPointHealthException(e);
            }
        });
}
 
开发者ID:spypunk,项目名称:endpoint-health,代码行数:19,代码来源:EndPointHealthServiceImpl.java

示例5: assertDirectoriesEqual

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
/**
 * Primitive DB comparison method
 * We just compare file names, not the subdirecory structure also
 * (so this would fail if multiple subdirectories had the same file name)
 */
public static void assertDirectoriesEqual(File expected, File actual) {
    MutableList<File> expectedFiles = FastList.newList(FileUtils.listFiles(expected, new WildcardFileFilter("*"),
            DIR_FILE_FILTER));
    expectedFiles = expectedFiles.sortThisBy(toRelativePath(expected));
    MutableList<File> actualFiles = FastList.newList(FileUtils.listFiles(actual, new WildcardFileFilter("*"),
            DIR_FILE_FILTER));
    actualFiles = actualFiles.sortThisBy(toRelativePath(actual));

    assertEquals(
            String.format("Directories did not have same # of files:\nExpected: %1$s\nbut was: %2$s",
                    expectedFiles.makeString("\n"), actualFiles.makeString("\n")),
            expectedFiles.size(), actualFiles.size());
    for (int i = 0; i < expectedFiles.size(); i++) {
        File expectedFile = expectedFiles.get(i);
        File actualFile = actualFiles.get(i);

        String expectedFilePath = getRelativePath(expectedFile, expected);
        String actualFilePath = getRelativePath(actualFile, actual);
        System.out.println("Comparing" + expectedFilePath + " vs " + actualFilePath);

        assertEquals("File " + i + " [" + expectedFile + " vs " + actualFile
                + " does not match paths relative from their roots", expectedFilePath, actualFilePath);
        FileAssert.assertEquals("Mismatch on file " + expectedFile.getAbsolutePath(), expectedFile, actualFile);
    }
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:31,代码来源:DirectoryAssert.java

示例6: getModels

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
/**
 * Gets the models.
 *
 * @return the models
 */
public static String[] getModels() {
	File dir = new File(Config.getConfiguration().getString(MODELPATH));

	LOG.info("Loading Models from... " + dir.getAbsolutePath());
	List<String> models = new ArrayList<>();
	String[] modelNames = getModelNames();

	List<String> wildCardPath = Arrays.stream(modelNames).map(model -> {
		return "en-ner-" + model + "*.bin";
	}).collect(Collectors.toList());

	FileFilter fileFilter = new WildcardFileFilter(wildCardPath,
			IOCase.INSENSITIVE);
	List<String> filePath = Arrays.asList(dir.listFiles(fileFilter))
			.stream().map(file -> file.getAbsolutePath())
			.collect(Collectors.toList());
	return filePath.toArray(new String[filePath.size()]);
}
 
开发者ID:TekstoSense,项目名称:opennlp-enhancer,代码行数:24,代码来源:ModelLoaderConfig.java

示例7: testSeeNewFiles

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
@Test
public void testSeeNewFiles() {

	MapTrackerMemory memory = new MapTrackerMemory();

	DirectoryPollingThread dpth = new DirectoryPollingThread("test",
			new SimpleFileDateExtractor(), memory);
	dpth.setDirectory(createFilesDir.getAbsolutePath());
	dpth.setFileFilter(new WildcardFileFilter("*.log"));

	dpth.run();

	assertEquals(newFilesArr.length, memory.getFileCount());

	// check that the memory contains all files in the newFilesArr
	for (File file : newFilesArr) {

		FileTrackingStatus status = memory.getFileStatus(file);
		assertNotNull(status);
		assertEquals("test", status.getLogType());
		assertEquals(file.lastModified(), status.getLastModificationTime());
		assertEquals(file.length(), status.getFileSize());

	}

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:27,代码来源:TestDirectoryPollingThread.java

示例8: getTempOutputStyles

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
public static File[] getTempOutputStyles() {
    if (tempDir == null || !tempDir.isDirectory())
        return null;

    // Unix-like searching for styles
    FileFilter styleFileFilter = new WildcardFileFilter("*.json");
    File[] files = tempDir.listFiles(styleFileFilter);

    if (files != null && files.length > 1) {
        long[] fileIters = new long[files.length];
        for (int i = 0; i < files.length; i++) {
            try {
                fileIters[i] = Long.valueOf(FileUtils.getFileName(files[i]).replace("_", ""));
            } catch (Exception e) {
                fileIters[i] = 0;
            }
        }
        FileUtils.quickSort(fileIters, files, 0, files.length - 1);
    }

    return files;
}
 
开发者ID:cameronleger,项目名称:neural-style-gui,代码行数:23,代码来源:FileUtils.java

示例9: getTempOutputImageIterations

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
public static File[] getTempOutputImageIterations(File outputImage) {
    if (tempDir == null || !tempDir.isDirectory() || outputImage == null)
        return null;

    // Unix-like searching for image iterations
    String outputImageBase = getFileName(outputImage);
    FileFilter fileFilter = new WildcardFileFilter(String.format("%s_*.png", outputImageBase));
    File[] files = tempDir.listFiles(fileFilter);

    // sort the files by the iteration progress
    if (files != null && files.length > 1) {
        int[] fileIters = new int[files.length];
        for (int i = 0; i < files.length; i++)
            fileIters[i] = FileUtils.parseImageIteration(files[i]);
        FileUtils.quickSort(fileIters, files, 0, files.length - 1);

        // if the latest file was still being written to during the check
        // then replace it with the previous file (set will remove it)
        if (isFileBeingWritten(files[files.length - 1]))
            files[files.length - 1] = files[files.length - 2];
    }

    return files;
}
 
开发者ID:cameronleger,项目名称:neural-style-gui,代码行数:25,代码来源:FileUtils.java

示例10: addEntriesFromDirectory

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
/**
 * Creates an entry for each file and calculate a md5 checksum for the file.
 * 
 * @param dir
 * @throws NoSuchAlgorithmException
 * @throws ExecutionException
 * @throws InterruptedException
 * @throws IOException
 */
public void addEntriesFromDirectory(String contractAddress,String dir)
		throws IOException, InterruptedException, ExecutionException, NoSuchAlgorithmException {
	setManager(contractAddress);
	MessageDigest md = MessageDigest.getInstance(algorithm);

	File directory = new File(dir);
	FilenameFilter filter = new WildcardFileFilter(fileFilter);

	String[] list = directory.list(filter);
	for (String filename : list) {
		String completetFilename = dir+"/"+filename;
		addSingleFile(md, completetFilename);
	}
	listChecksumData(manager.contractAddress.withLeading0x());
}
 
开发者ID:UrsZeidler,项目名称:checksumDatabase,代码行数:25,代码来源:ChecksumManager.java

示例11: getHighestVersions

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
/**
 * Returns all repositories found until now with the highest version that we
 * found for them.
 *
 * @return repo as key, highest seen version as value
 * @throws IOException If a file cannot be read
 */
public static Map<String, String> getHighestVersions() throws IOException {
    // read stats
    File[] files = STATS_DIR.listFiles((FilenameFilter)new WildcardFileFilter("stats*.json"));
    Preconditions.checkNotNull(files);

    Arrays.sort(files);

    Map<String, String> seenRepositoryVersions = new HashMap<>();
    for(File file : files) {
        List<String> lines = FileUtils.readLines(file, "UTF-8");
        for (String line : lines) {
            Holder holder = mapper.readValue(line, Holder.class);
            // now update the map of highest version per Repository for the next date
            addHigherVersions(seenRepositoryVersions, holder.getRepositoryVersions());
        }
    }

    return seenRepositoryVersions;
}
 
开发者ID:centic9,项目名称:github-version-statistics,代码行数:27,代码来源:JSONWriter.java

示例12: getFileOrFiles

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
public static Stream<Path> getFileOrFiles(Path fileOrDirectory, String filterExpression) {
    File[] files;
    PathMatcher matcher = FileSystems.getDefault().getPathMatcher(filterExpression);

    if(fileOrDirectory.getFileName().toString().contains("*"))
        return Lists.newArrayList(fileOrDirectory.toFile()
                .getParentFile()
                .listFiles((FileFilter)new WildcardFileFilter(
                        fileOrDirectory.getFileName().toString())))
                .stream()
                .map(File::toPath)
                .filter(p -> matcher.matches(p.getFileName()));
    else if(fileOrDirectory.toFile().isDirectory() && (files = fileOrDirectory.toFile().listFiles()) != null)
        return Lists.newArrayList(files)
                    .stream()
                    .map(File::toPath)
                    .filter(p -> p.toFile().isDirectory() || matcher.matches(p.getFileName()));
    else
        return Lists.newArrayList(new Path[] {fileOrDirectory}).stream();
}
 
开发者ID:uwdb,项目名称:pipegen,代码行数:21,代码来源:PathUtilities.java

示例13: getTheNewestFile

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
public File getTheNewestFile(File directory, String extension) {
    File newestFile = null;
    if (directory == null || !directory.exists() || !directory.isDirectory()) {
    	return newestFile;
    }

    FileFilter fileFilter = new WildcardFileFilter("*." + extension);
    File[] files = directory.listFiles(fileFilter);

    if (files.length > 0) {
        Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
        newestFile = files[0];
    }

    return newestFile;
}
 
开发者ID:fastconnect,项目名称:tibco-fcunit,代码行数:17,代码来源:MenuPage.java

示例14: getReportTemplate

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
public ReportTemplate getReportTemplate(String templateName) throws ProviderException
{		
	File reportDirectory = new File(directoryProvider.getReportDirectory());		
	FileFilter templateFilter = new WildcardFileFilter(templateName + "*");
    File[] templateFiles = reportDirectory.listFiles(templateFilter);
    
    String[] revisions = new String[templateFiles.length];
    for (int i=0; i <  templateFiles.length; i++)
    {
    	revisions[i] = templateFiles[i].getName();
    }
    
    Arrays.sort(revisions);
    
    ReportTemplate template = new ReportTemplate(templateName);
    template.setRevisions(revisions);		 
	
	return template;
}
 
开发者ID:mtpettyp,项目名称:openreports,代码行数:20,代码来源:ReportProviderImpl.java

示例15: load

import org.apache.commons.io.filefilter.WildcardFileFilter; //导入依赖的package包/类
/**
 * Loads files from the given directory with the extensions specified by the text fields of the accessory.
 *
 * @param file the directory load the corpus from.
 * @param from the starting instance index.
 * @param to   the end instance index.
 * @return a list of NLP instances loaded from the given file in the given interval.
 * @throws java.io.IOException if I/O goes wrong.
 */
public List<NLPInstance> load(final File file,
                              final int from,
                              final int to) throws IOException {
    ArrayList<NLPInstance> result = new ArrayList<NLPInstance>();
    int index = 0;
    for (final File txtFile : file.listFiles((FileFilter)
        new WildcardFileFilter("*." + txtExtensionField.getText().trim()))) {
        String filename = txtFile.getAbsolutePath();
        String prefix = filename.substring(0, filename.lastIndexOf("."));
        File proteinFile = new File(prefix + "." +
            proteinExtensionField.getText().trim());
        File eventFile = new File(prefix + "." +
            eventExtensionField.getText().trim());
        if (proteinFile.exists() && eventFile.exists()) {
            result.add(load(txtFile, proteinFile, eventFile));
            monitor.progressed(index++);
        }
    }
    return result;
}
 
开发者ID:riedelcastro,项目名称:whatswrong,代码行数:30,代码来源:BioNLP2009SharedTaskFormat.java


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