类org.apache.commons.io.filefilter.WildcardFileFilter源码实例Demo

下面列出了怎么用org.apache.commons.io.filefilter.WildcardFileFilter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: netcdf-java   文件: TestSigmet.java
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> getTestParameters() throws IOException {
  final Collection<Object[]> filenames = new ArrayList<>();

  try {
    TestDir.actOnAll(TestDir.cdmUnitTestDir + "formats/sigmet/", new WildcardFileFilter("*IRIS"), new TestDir.Act() {
      public int doAct(String filename) throws IOException {
        filenames.add(new Object[] {filename});
        return 1;
      }
    }, true);
  } catch (IOException e) {
    // JUnit *always* executes a test class's @Parameters method, even if it won't subsequently run the class's tests
    // due to an @Category exclusion. Therefore, we must not let it throw an exception, or else we'll get a build
    // failure. Instead, we return a collection containing a nonsense value (to wit, the exception message).
    //
    // Naturally, if we execute a test using that nonsense value, it'll fail. That's fine; we need to deal with the
    // root cause. However, it is more likely that the exception occurred because "!isCdmUnitTestDirAvailable", and
    // as a result, all NeedsCdmUnitTest tests will be excluded.
    filenames.add(new Object[] {e.getMessage()});
  }

  return filenames;
}
 
源代码2 项目: synopsys-detect   文件: MockFileFinder.java
@Override
public List<File> findFiles(final File directoryToSearch, final List<String> filenamePatterns, final int depth, boolean findInsideMatchingDirectories) {
    List<File> found = new ArrayList<>();
    for (int i = 0; i <= depth; i++) {
        if (files.containsKey(i)) {
            List<File> possibles = files.get(i);
            for (String pattern : filenamePatterns) {
                FileFilter fileFilter = new WildcardFileFilter(pattern);
                for (File possible : possibles) {
                    if (fileFilter.accept(possible)) {
                        found.add(possible);
                    }
                }

            }
        }
    }
    return found;
}
 
源代码3 项目: datawave   文件: FlagMaker.java
/**
 * Determine the number of unprocessed flag files in the flag directory
 * 
 * @param fc
 * @return the flag found for this ingest pool
 */
private int countFlagFileBacklog(final FlagDataTypeConfig fc) {
    final MutableInt fileCounter = new MutableInt(0);
    final FileFilter fileFilter = new WildcardFileFilter("*_" + fc.getIngestPool() + "_" + fc.getDataName() + "_*.flag");
    final FileVisitor<java.nio.file.Path> visitor = new SimpleFileVisitor<java.nio.file.Path>() {
        
        @Override
        public FileVisitResult visitFile(java.nio.file.Path path, BasicFileAttributes attrs) throws IOException {
            if (fileFilter.accept(path.toFile())) {
                fileCounter.increment();
            }
            return super.visitFile(path, attrs);
        }
    };
    try {
        Files.walkFileTree(Paths.get(fmc.getFlagFileDirectory()), visitor);
    } catch (IOException e) {
        // unable to get a flag count....
        log.error("Unable to get flag file count", e);
        return -1;
    }
    return fileCounter.intValue();
}
 
源代码4 项目: elasticsearch-pool   文件: ResourceUtils.java
private static URL[] load3(String locationPattern) throws MalformedURLException {
    if (StringUtils.contains(locationPattern, PunctuationConstants.STAR.getValue())
            || StringUtils.contains(locationPattern, PunctuationConstants.QUESTION_MARK.getValue())) {
        String directoryPath = StringUtils.substringBeforeLast(locationPattern,
                ResourceConstants.FOLDER_SEPARATOR.getValue());
        directoryPath = StringUtils.substringAfter(directoryPath, ResourceConstants.FILE_URL_PREFIX.getValue());
        File directory = new File(directoryPath);
        String filePattern = StringUtils.substringAfter(locationPattern,
                ResourceConstants.FOLDER_SEPARATOR.getValue());
        while (filePattern.contains(ResourceConstants.FOLDER_SEPARATOR.getValue())) {
            filePattern = StringUtils.substringAfter(filePattern, ResourceConstants.FOLDER_SEPARATOR.getValue());
        }

        Set<URL> result = new LinkedHashSet<URL>(16);
        Iterator<File> iterator = FileUtils.iterateFiles(directory, new WildcardFileFilter(filePattern), null);
        while (iterator.hasNext()) {
            result.add(iterator.next().toURI().toURL());
        }

        return result.toArray(new URL[result.size()]);
    } else {
        // a single resource with the given name
        URL url = new URL(locationPattern);
        return new File(url.getFile()).exists() ? new URL[] { url } : null;
    }
}
 
private void copyImagesAndCertificates(String origConfigFile, TestContext context) {
	File sourceDir = new File(origConfigFile).getParentFile();
	if(!sourceDir.exists()) {
		sourceDir = new File(ImportTestAction.class.getResource(origConfigFile).getFile()).getParentFile();
		if(!sourceDir.exists()) { 
			return;
		}
	}
	FileFilter filter = new WildcardFileFilter(new String[] {"*.crt", "*.jpg", "*.png", "*.pem"});
	try {
		LOG.info("Copy certificates and images from source: "+sourceDir+" into test-dir: '"+testDir+"'");
		FileUtils.copyDirectory(sourceDir, testDir, filter);
	} catch (IOException e) {

	}
}
 
源代码6 项目: o2oa   文件: MetaModelBuilder.java
private static List<File> classpath(File o2oadir, File outputdir) {
	List<File> cp = new ArrayList<>();

	cp.add(outputdir);

	IOFileFilter filter = new WildcardFileFilter("x_base_core_project.jar");
	for (File o : FileUtils.listFiles(new File(o2oadir, "o2server/store/jars"), filter, null)) {
		cp.add(o);
	}

	ClassLoader cl = MetaModelBuilder.class.getClassLoader();

	URL[] urls = ((URLClassLoader) cl).getURLs();

	for (URL url : urls) {
		cp.add(new File(url.getFile()));
	}
	return cp;
}
 
源代码7 项目: o2oa   文件: NodeAgent.java
private void customJar(String simpleName, byte[] bytes) throws Exception {
	File jar = new File(Config.dir_custom_jars(true), simpleName + ".jar");
	FileUtils.writeByteArrayToFile(jar, bytes, false);
	List<String> contexts = new ArrayList<>();
	for (String s : Config.dir_custom().list(new WildcardFileFilter("*.war"))) {
		contexts.add("/" + FilenameUtils.getBaseName(s));
	}
	if (Servers.applicationServerIsRunning()) {
		GzipHandler gzipHandler = (GzipHandler) Servers.applicationServer.getHandler();
		HandlerList hanlderList = (HandlerList) gzipHandler.getHandler();
		for (Handler handler : hanlderList.getHandlers()) {
			if (QuickStartWebApp.class.isAssignableFrom(handler.getClass())) {
				QuickStartWebApp app = (QuickStartWebApp) handler;
				if (contexts.contains(app.getContextPath())) {
					app.stop();
					Thread.sleep(2000);
					app.start();
				}
			}
		}
	}
}
 
源代码8 项目: neural-style-gui   文件: FileUtils.java
public static File[] getTempOutputImageIterations(File outputImage) {
    // Unix-like searching for image iterations
    String outputImageBase = getFileName(outputImage);
    FileFilter fileFilter = new WildcardFileFilter(String.format("%s_*.png", outputImageBase));
    File[] files = NeuralStyleWrapper.getWorkingFolder().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;
}
 
源代码9 项目: MtgDesktopCompanion   文件: FileDAO.java
@Override
public List<MagicCardStock> listStocks(MagicCard mc, MagicCollection col,boolean editionStrict) throws SQLException {
	List<MagicCardStock> st = new ArrayList<>();
	File f = new File(directory, STOCKDIR);
	for (File fstock : FileUtils.listFiles(f, new WildcardFileFilter("*" + IDGenerator.generate(mc)),TrueFileFilter.INSTANCE)) {
		try {
			MagicCardStock s = read(MagicCardStock.class, fstock);
			if (s.getMagicCollection().getName().equals(col.getName()))
				st.add(s);

		} catch (Exception e) {
			throw new SQLException(e);
		}
	}

	return st;
}
 
源代码10 项目: spoon-maven-plugin   文件: SpoonMojoTest.java
@Test
public void testSpoonGoalWithAProcessor() throws Exception {
	File basedir = resources.getBasedir("processor");
	rule.executeMojo(basedir, "generate");

	final File dirOutputResults = new File(basedir, "target/spoon-maven-plugin");
	assertThat(dirOutputResults).exists();

	final WildcardFileFilter filter = new WildcardFileFilter("result-spoon-*.xml");
	final File[] files = dirOutputResults.listFiles((FileFilter) filter);
	assertThat(files.length).isEqualTo(1);
	assertThat(files[0].getName()).startsWith("result-spoon");

	final File resultFileProcessor = new File(basedir, "target/spoon-maven-plugin/spoon-nb-statement.txt");
	assertThat(resultFileProcessor).exists();
}
 
源代码11 项目: spoon-maven-plugin   文件: SpoonMojoTest.java
@Test
public void testSpoonGoalWithCustomPConfiguration() throws Exception {
	File basedir = resources.getBasedir("custom-configuration");
	rule.executeMojo(basedir, "generate");

	final File dirOutputResults = new File(basedir, "target/spoon-maven-plugin");
	assertThat(dirOutputResults).exists();

	final WildcardFileFilter filter = new WildcardFileFilter("result-spoon-*.xml");
	final File[] files = dirOutputResults.listFiles((FileFilter) filter);
	assertThat(files.length).isEqualTo(1);
	assertThat(files[0].getName()).startsWith("result-spoon");

	File generateFiles = new File(basedir, "target/generate-source-with-spoon");
	assertThat(generateFiles).exists();
}
 
源代码12 项目: spoon-maven-plugin   文件: SpoonMojoTest.java
@Test
public void testSpoonCheckGoalWithTest() throws Exception {
	File basedir = resources.getBasedir("hello-world-with-test");
	rule.executeMojo(basedir, "check");

	final File dirOutputResults = new File(basedir, "target/spoon-maven-plugin");
	assertThat(dirOutputResults).exists();

	final File contentSource = new File(basedir, "target/generated-sources/spoon/fr/inria/gforge/spoon");
	assertThat(contentSource).doesNotExist();

	final WildcardFileFilter filter = new WildcardFileFilter("result-spoon-*.xml");
	final File[] files = dirOutputResults.listFiles((FileFilter) filter);
	assertThat(files.length).isEqualTo(1);
	assertThat(files[0].getName()).startsWith("result-spoon");
}
 
源代码13 项目: elasticsearch-pool   文件: ResourceUtils.java
private static URL[] load2(String locationPattern) throws URISyntaxException, IOException {
    String location = locationPattern.substring(ResourceConstants.CLASSPATH_URL_PREFIX.getValue().length());
    if (location.startsWith(ResourceConstants.FOLDER_SEPARATOR.getValue())) {
        location = location.substring(1);
    }

    String cleanPath = PathUtils.cleanPath(location);
    // 只支持文件的通配符匹配,不支持文件夹的通配符匹配
    // 如需实现文件夹的通配符匹配,请参照spring.utils包,较复杂
    if (StringUtils.contains(cleanPath, PunctuationConstants.STAR.getValue())
            || StringUtils.contains(cleanPath, PunctuationConstants.QUESTION_MARK.getValue())) {
        String directoryPath = StringUtils.substringBeforeLast(locationPattern,
                ResourceConstants.FOLDER_SEPARATOR.getValue());
        File directory = new File(ResourceUtils.loadResource(directoryPath).toURI().getPath());

        String filePattern = StringUtils.substringAfter(cleanPath, ResourceConstants.FOLDER_SEPARATOR.getValue());
        while (filePattern.contains(ResourceConstants.FOLDER_SEPARATOR.getValue())) {
            filePattern = StringUtils.substringAfter(filePattern, ResourceConstants.FOLDER_SEPARATOR.getValue());
        }

        Set<URL> result = new LinkedHashSet<URL>(16);
        Iterator<File> iterator = FileUtils.iterateFiles(directory, new WildcardFileFilter(filePattern), null);
        while (iterator.hasNext()) {
            result.add(iterator.next().toURI().toURL());
        }

        return result.toArray(new URL[result.size()]);
    } else {
        // a single resource with the given name
        URL url = getDefaultClassLoader().getResource(cleanPath);
        // if (url == null) {
        // throw new UnsupportedOperationException(cleanPath);
        // }
        return url == null ? null : new URL[] { PathUtils.cleanPath(url) };
    }
}
 
源代码14 项目: Drop-seq   文件: FileListParsingUtils.java
public static Collection<File> expandWildcardFile(final File wildcardFile) {
    final String fileName = wildcardFile.getName();
    if (fileName.contains("*") || fileName.contains("?"))
        return FileUtils.listFiles(wildcardFile.getParentFile(), new WildcardFileFilter(wildcardFile.getName()), null);
    else
        return Collections.singleton(wildcardFile);
}
 
源代码15 项目: o2oa   文件: ApplicationServerTools.java
private static List<String> listCustom() throws Exception {
	List<String> list = new ArrayList<>();
	for (String str : Config.dir_custom(true).list(new WildcardFileFilter("*.war"))) {
		list.add(FilenameUtils.getBaseName(str));
	}
	list = ListTools.includesExcludesWildcard(list, Config.currentNode().getApplication().getIncludes(),
			Config.currentNode().getApplication().getExcludes());
	return list;
}
 
源代码16 项目: opentest   文件: ListFiles.java
@Override
public void run() {
    super.run();

    String directoryPath = readStringArgument("directory");
    String pattern = readStringArgument("pattern", "*");
    // Some valid orderBy values: "date", "date, desc", "name", "size"
    String orderBy = readStringArgument("orderBy", "name");

    List<File> files;
    File directory = new File(directoryPath);
    if (directory.exists()) {
        FileFilter fileFilter = new WildcardFileFilter(pattern);
        files = Arrays.asList(directory.listFiles(fileFilter));
    } else {
        log.warning(String.format("Directory \"%s\" doesn't exist", directoryPath));
        files = new ArrayList<File>(0);
    }

    if (orderBy != null) {
        if (orderBy.matches("^\\s*date.*")) {
            files = files.stream().sorted(Comparator.comparing(File::lastModified)).collect(Collectors.toList());
        } else if (orderBy.matches("^\\s*name.*")) {
            files = files.stream().sorted(Comparator.comparing(File::getName)).collect(Collectors.toList());
        } else if (orderBy.matches("^\\s*size.*")) {
            files = files.stream().sorted(Comparator.comparing(File::length)).collect(Collectors.toList());
        }

        if (orderBy.matches(".*,\\s*desc\\s*$")) {
            Collections.reverse(files);
        }
    }

    this.writeOutput("files", files);
    if (files.size() > 0) {
        this.writeOutput("firstFile", files.size() > 0 ? files.get(0) : null);
        this.writeOutput("lastFile", files.size() > 0 ? files.get(files.size() - 1) : null);
    }
}
 
源代码17 项目: obevo   文件: DirectoryAssert.java
/**
 * Primitive DB comparison method
 * We just compare file names, not the subdirectory structure also
 * (so this would fail if multiple subdirectories had the same file name)
 */
public static void assertDirectoriesEqual(File expected, File actual, boolean ignoreWhitespace) {
    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);
        LOG.info("Comparing {} vs {}", expectedFilePath, actualFilePath);
        assertEquals("File " + i + " [" + expectedFile + " vs " + actualFile
                + " does not match paths relative from their roots", expectedFilePath, actualFilePath);

        if (ignoreWhitespace) {
            String expectedContent = FileUtilsCobra.readFileToString(expectedFile);
            String actualContent = FileUtilsCobra.readFileToString(actualFile);
            assertThat(actualContent, Matchers.equalToIgnoringWhiteSpace(expectedContent));
        } else {
            FileAssert.assertEquals("Mismatch on file " + expectedFile.getAbsolutePath(), expectedFile, actualFile);
        }
    }
}
 
源代码18 项目: synthea   文件: ModuleOverrides.java
/**
 * Create a ModuleOverrides object which will process the modules according to the given options.
 * 
 * @param includeFields - List of field names to include
 * @param includeModulesList - list of module filename rules to include
 * @param excludeFields - list of field names to exclude
 * @param excludeModulesList - list of module filename rules to exclude
 */
public ModuleOverrides(List<String> includeFields, List<String> includeModulesList,
    List<String> excludeFields, List<String> excludeModulesList) {
  this.includeFields = includeFields;
  this.excludeFields = excludeFields;

  if (includeModulesList != null) {
    this.includeModules = new WildcardFileFilter(includeModulesList, IOCase.INSENSITIVE);
  }
  if (excludeModulesList != null) {
    this.excludeModules = new WildcardFileFilter(excludeModulesList, IOCase.INSENSITIVE);
  }
}
 
源代码19 项目: synthea   文件: Generator.java
private Predicate<String> getModulePredicate() {
  if (options.enabledModules == null) {
    return path -> true;
  }
  FilenameFilter filenameFilter = new WildcardFileFilter(options.enabledModules, 
      IOCase.INSENSITIVE);
  return path -> filenameFilter.accept(null, path);
}
 
源代码20 项目: TranskribusCore   文件: LocalFimagestoreClient.java
public static File getFile(File dir, String fileType) throws FileNotFoundException {
		if (fileType.equals(FILE_TYPE_METADATA))
			return getMetadataFile(dir);
		
//		FileMetadata metadata = MetadataParser.parseMetadata(dir);
//		
//		// if fileType = browser and original file is browser compatible then return original file:
//		if (fileType.equals(FImagestoreVars.FILE_TYPE_BROWSER) && 
//				MimeTypes.isImageMimeTypeBrowserCompatible(metadata.Mimetype)) {
////			return getOrigFile(dir);
//			fileType=FImagestoreVars.FILE_TYPE_ORIG;
//		}
//		// else if fileType = view and original file is binarized then return original file:
//		if (fileType.equals(ImagestoreVars.FILE_TYPE_VIEW) && metadata.imgMetadata.NComponents==1) {
//			return getOrigFile(dir);
//		}
		
		// else: get file of type fileType:
//		List<File> files = (List<File>) FileUtils.listFiles(dir, new WildcardFilter(fileType+"_*.*"), null);
		List<File> files = (List<File>) FileUtils.listFiles(dir, new WildcardFileFilter(fileType+"_*.*"), null);
		
		if (files.size()==0)
			throw new FileNotFoundException("File of type "+fileType+" not found in dir: "+dir.getAbsolutePath());
		else if (files.size()>1)
			throw new FileNotFoundException("File of type "+fileType+" is duplicate in dir: "+dir.getAbsolutePath());
		else
			return files.get(0);
	}
 
@Ignore
@Test
public void testAppUpdate() throws InterruptedException {
	String[] args = {"-updateApp"};
	ModpackDownloaderCLI.main(args);
	FileFilter fileFilter = new WildcardFileFilter("ModpackDownloader*jar");
	File directory = new File(".");
	List<File> files = Arrays.asList(directory.listFiles(fileFilter));
	Assert.assertTrue(!CollectionUtils.isEmpty(files));
	files.forEach(File::deleteOnExit);
}
 
源代码22 项目: flux   文件: WorkflowExecutionDemo.java
/**
 * Does necessary actions to run an example/user's workflow.
 * @param moduleName name of user module in which workflow code is present
 * @param workflowClassFQN fully qualified name of main class which triggers user workflow execution at client side.
 *                         @see com.flipkart.flux.examples.concurrent.RunEmailMarketingWorkflow for example.
 * @param configFileName "flux_config.yml" which contains workflow related configuration.
 *                       @see flux/examples/src/main/resources/flux_config.yml for example.
 * @throws Exception
 */
private static void runExample(String moduleName, String workflowClassFQN, String configFileName, String mavenPath) throws Exception {

    //copy dependencies to module's target directory
    executeCommand(mavenPath+" -pl " + moduleName + " -q package dependency:copy-dependencies -DincludeScope=runtime -DskipTests");

    //get deployment path from configuration.yml
    FileReader reader = new FileReader(WorkflowExecutionDemo.class.getResource("/packaged/configuration.yml").getFile());
    String deploymentUnitsPath = (String) ((Map)new Yaml().load(reader)).get("deploymentUnitsPath");
    if(!deploymentUnitsPath.endsWith("/")) {
        deploymentUnitsPath = deploymentUnitsPath + "/";
    }
    reader.close();

    //create deployment structure
    String deploymentUnitName = "DU1/1";
    String mainDirPath = deploymentUnitsPath + deploymentUnitName + "/main";
    String libDirPath = deploymentUnitsPath + deploymentUnitName + "/lib";
    executeCommand("mkdir -p " + mainDirPath);
    executeCommand("mkdir -p " + libDirPath);

    //copy dependencies to deployment unit
    FileUtils.copyFile(new File(moduleName + "/target/").listFiles((FilenameFilter) new WildcardFileFilter(moduleName + "*.jar"))[0], new File(mainDirPath + "/" + moduleName + ".jar"));
    FileUtils.copyDirectory(new File(moduleName + "/target/dependency"), new File(libDirPath));
    FileUtils.copyFile(new File(moduleName + "/src/main/resources/" + configFileName), new File(deploymentUnitsPath + deploymentUnitName + "/flux_config.yml"));

    //start flux runtime
    FluxInitializer.main(new String[]{});

    //Invoke workflow in separate process, the below system out prints this process's output in blue color
    System.out.println((char)27 + "[34m"+executeCommand("java -cp " + moduleName +"/target/*:" + moduleName + "/target/dependency/* " + workflowClassFQN) + (char)27 + "[0m");
}
 
源代码23 项目: logsniffer   文件: RollingLogsSource.java
protected Log[] getPastLogs(final String liveLog) throws IOException {
	final File dir = new File(FilenameUtils.getFullPathNoEndSeparator(liveLog));
	final String pastPattern = FilenameUtils.getName(liveLog) + getPastLogsSuffixPattern();
	final FileFilter fileFilter = new WildcardFileFilter(pastPattern);
	final File[] files = dir.listFiles(fileFilter);
	final FileLog[] logs = new FileLog[files.length];
	Arrays.sort(files, getPastLogsType().getPastComparator());
	int i = 0;
	for (final File file : files) {
		// TODO Decouple direct file log association
		logs[i++] = new FileLog(file);
	}
	logger.debug("Found {} past logs for {} with pattern {}", logs.length, liveLog, pastPattern);
	return logs;
}
 
源代码24 项目: eagle   文件: CoprocessorJarUtils.java
public static File getCoprocessorJarFile() {
    String projectRootDir = System.getProperty("user.dir");
    String targetDirPath = projectRootDir + "/target/";
    File targetDirFile = new File(targetDirPath);
    if (!targetDirFile.exists()) {
        throw new IllegalStateException(targetDirPath + " not found, please execute 'mvn install -DskipTests' under " + projectRootDir + " to build the project firstly and retry");
    }
    String jarFileNameWildCard = "eagle-storage-hbase-*-coprocessor.jar";
    Collection<File> jarFiles = FileUtils.listFiles(targetDirFile, new WildcardFileFilter(jarFileNameWildCard), TrueFileFilter.INSTANCE);
    if (jarFiles.size() == 0) {
        throw new IllegalStateException("jar is not found, please execute 'mvn package -DskipTests' from project root firstly and retry");
    }
    return jarFiles.iterator().next();
}
 
源代码25 项目: robot   文件: CommandLineHelper.java
/**
 * Given a wildcard pattern as string, return an array of files matching that pattern.
 *
 * @param pattern wildcard pattern to match
 * @return array of files
 * @throws IllegalArgumentException on bad pattern
 */
private static File[] getFilesByPattern(String pattern) throws IllegalArgumentException {
  if (!pattern.contains("*") && !pattern.contains("?")) {
    throw new IllegalArgumentException(wildcardError);
  }
  FileFilter fileFilter = new WildcardFileFilter(pattern);
  File[] files = new File(".").listFiles(fileFilter);
  if (files == null || files.length < 1) {
    // Warn user, but continue (empty input checked later)
    logger.error("No files match pattern: {}", pattern);
  }
  return files;
}
 
private List<Path> resolveIncludePattern(String includePattern) {
    if (includePattern.contains("*")) {
        String[] dirs = includePattern.split(File.separator);
        String pattern = dirs[dirs.length - 1];
        File basedir = new File(mavenProject.getBasedir(), includePattern.replace(pattern, ""));

        return FileUtils
                .listFiles(basedir, new WildcardFileFilter(pattern), null)
                .stream()
                .map(File::toPath)
                .collect(Collectors.toList());
    } else {
        return Collections.singletonList(mavenProject.getBasedir().toPath().resolve(includePattern));
    }
}
 
public static Collection<File> getPomFiles( File repoPath )
{
    Collection<File> pomFiles = new ArrayList<File>();
    Collection<File> leafDirectories = getLeafDirectories( repoPath );
    for ( File leafDirectory : leafDirectories )
    {
        IOFileFilter fileFilter = new AndFileFilter( new WildcardFileFilter( "*.pom" ),
                                           new NotFileFilter( new SuffixFileFilter( "sha1" ) ) );
        pomFiles.addAll( FileUtils.listFiles( leafDirectory, fileFilter, null ) );
    }
    return pomFiles;
}
 
源代码28 项目: knox   文件: GatewayBasicFuncTest.java
private File findFile( File dir, String pattern ) {
  File file = null;
  FileFilter filter = new WildcardFileFilter( pattern );
  File[] files = dir.listFiles(filter);
  if( files != null && files.length > 0 ) {
    file = files[0];
  }
  return file;
}
 
源代码29 项目: oxTrust   文件: CacheRefreshSnapshotFileService.java
private String[] getSnapshotsList(CacheRefreshConfiguration cacheRefreshConfiguration) {
	File file = new File(cacheRefreshConfiguration.getSnapshotFolder());
	String[] files = file.list(new WildcardFileFilter(String.format(SNAPSHOT_FILE_NAME_PATTERN, "*")));
	Arrays.sort(files);

	return files;
}
 
源代码30 项目: oxTrust   文件: ViewLogFileAction.java
private Map<Integer, String> prepareLogFiles() {
	Map<Integer, String> logFiles = new HashMap<Integer, String>();

	int fileIndex = 0;
	for (SimpleCustomProperty logTemplate : this.logViewerConfiguration.getLogTemplates()) {
		String logTemplatePattern = logTemplate.getValue2();
		if (StringHelper.isEmpty(logTemplatePattern)) {
			continue;
		}

		String logTemplatePath = FilenameUtils.getFullPath(logTemplatePattern);
		String logTemplateFile = FilenameUtils.getName(logTemplatePattern);

		File logTemplateBaseDir = new File(logTemplatePath);

		FileFilter fileFilter = new AndFileFilter(FileFileFilter.FILE, new WildcardFileFilter(logTemplateFile));
		File[] files = logTemplateBaseDir.listFiles(fileFilter);
		if (files == null) {
			continue;
		}

		for (int i = 0; i < files.length; i++) {
			logFiles.put(fileIndex++, files[i].getPath());
		}
	}

	return logFiles;
}
 
 类所在包
 同包方法