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


Java NameFileFilter类代码示例

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


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

示例1: cleanupDotContent

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
public static void cleanupDotContent(String root, String[] contentProperties) throws MojoExecutionException {
	for (File file : FileUtils.listFiles(new File(root), new NameFileFilter(".content.xml"),
			TrueFileFilter.INSTANCE)) {
		try {
			LOG.info("Cleaning up {}", file.getPath());
			List<String> lines = new ArrayList<String>();
			for (String line : FileUtils.readLines(file, CharEncoding.UTF_8)) {
				String cleanLine = StringUtils.trimToEmpty(line);
				boolean lineContains = lineContainsProperty(cleanLine, contentProperties);
				if (lineContains) {
					if (!cleanLine.endsWith(">")) {
					} else {
						String lastLine = lines.remove(lines.size() - 1);
						lines.add(lastLine + ">");
					}
				} else {
					lines.add(line);
				}
			}
			FileUtils.writeLines(file, CharEncoding.UTF_8, lines);
		} catch (IOException e) {
			throw new MojoExecutionException(String.format("Error opening %s", file.getPath()), e);
		}
	}
}
 
开发者ID:Cognifide,项目名称:Maven-Vault-Checkout-Plugin,代码行数:26,代码来源:CleanHelper.java

示例2: ReloadableConfig

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
public ReloadableConfig() {
    new Thread(()->{
        long interval = TimeUnit.SECONDS.toMillis(30);
        try {
            ClassPathResource resource = new ClassPathResource(getClassPathFilePath());
            File file = resource.getFile();
            FileAlterationObserver observer = new FileAlterationObserver(file.getParentFile() , new NameFileFilter(file.getName()));
            observer.addListener(this);
            FileAlterationMonitor monitor = new FileAlterationMonitor(interval , observer);
            LOGGER.debug("监听文件:{}" , file.getPath());
            monitor.start();
        } catch (Exception e) {
            LOGGER.error("ClassPathFilePath:{}" , getClassPathFilePath());
            LOGGER.error("" , e);
        }
    }).start();
}
 
开发者ID:JasonChanBest,项目名称:prometheus,代码行数:18,代码来源:ReloadableConfig.java

示例3: initWebApps

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
private void initWebApps() throws Exception {
  File webAppsDir = new File(homeDir, "webapps");    
  File[] dirs = webAppsDir.listFiles((FileFilter) DirectoryFileFilter.DIRECTORY);
  for (File dir : dirs) {
    File[] webAppFiles = dir.listFiles((FilenameFilter) new NameFileFilter("webapp.xml"));
    if (webAppFiles.length == 0) {
      continue;
    }
    File file = webAppFiles[0];
    try {       
      WebApp webApp = new WebApp(webAppFiles[0]);
      webApps.put(webApp.getName(), webApp);  
      webApp.open();
    } catch (Exception e) {
      logger.error(String.format("Error creating webapp \"%s\"", file.getAbsolutePath()), e);
    }
  }    
}
 
开发者ID:Armatiek,项目名称:xslweb,代码行数:19,代码来源:Context.java

示例4: findImageFile

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
private File findImageFile(File lookupFolder, String lookupTarget) {
    // given file can contain sub-folders in its name
    String[] paths = lookupTarget.split("[/\\\\]");
    String[] foldersToFind = Arrays.copyOfRange(paths, 0, paths.length - 1);

    for (String folderToFind : foldersToFind) {
        lookupFolder = findFolderRecursively(lookupFolder, folderToFind);
        if (lookupFolder == null) {
            return null;
        }
    }
    lookupTarget = paths[paths.length - 1];

    // finally searching for file name recursively
    Collection<File> files = listFiles(lookupFolder, new NameFileFilter(lookupTarget), TRUE);
    return files.isEmpty() ? null : files.iterator().next();
}
 
开发者ID:sterodium,项目名称:selenium-grid-extensions,代码行数:18,代码来源:TargetFactory.java

示例5: findContentFile

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
/**
 * Finds content file in directory (or subdirectory) that 'corresponds' to
 * passed metadata file.
 * 
 * In our case 'corresponding' files means that files have the same name base
 * but extensions may differ.
 * Extension of returned file must be one of the {@link #setEligibleFileExtensions(String[])}
 */
public File findContentFile(File contentDir, File correspondingMetadataFile) {
    String filenameBase = extractFilenameBase(correspondingMetadataFile.getName());
    
    List<String> possibleFileNames = buildPossibleFilenames(filenameBase);
    
    Collection<File> foundContentFiles = FileUtils.listFiles(contentDir, new NameFileFilter(possibleFileNames), TrueFileFilter.INSTANCE);
    
    if (foundContentFiles.size() == 0) {
        throw new ImportException("No content file was found for " + correspondingMetadataFile + " in " + contentDir.getPath());
    }
    if (foundContentFiles.size() > 1) {
        throw new ImportException("More than one file found as content file candidate of " + correspondingMetadataFile);
    }
    
    return foundContentFiles.iterator().next();
}
 
开发者ID:CeON,项目名称:saos,代码行数:25,代码来源:ContentSourceFileFinder.java

示例6: getPathForFile

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
/**
 * Return the path of a file. 
 * First checks presence in IAD directory, if not return results as path for the file.
 * It expects a file in the format of filename.extension.
 * @param filename
 * @return the path of a file
 */
// FIXME: this method should be moved elsewhere
public static File getPathForFile(String filename)
{
	File iad = new File(Dynamic.getIadPath());
	File result = new File(Dynamic.getResultsPath());
	
	String[] iad_list = iad.list(new NameFileFilter(filename));
	String[] result_list = result.list(new NameFileFilter(filename));
	
	
	if (iad_list.length > 0 && result_list.length > 0)
		LogST.logP(0, "*** WARNING: found the file "+filename+" both in IAD and RESULTs. Now reading from RESULTS.");
	
	if (result_list.length > 0)
		return result;
	else if (iad_list.length > 0)
		return iad;
	else
		return result;
}
 
开发者ID:hpclab,项目名称:TheMatrixProject,代码行数:28,代码来源:TempFileManager.java

示例7: getIndexPageURL

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
public String getIndexPageURL()  {
    try {
        File testOutputFolder = artifactsService.findArtifact(job.getIdentifier(), TEST_OUTPUT_FOLDER);

        if (testOutputFolder.exists()) {
            Collection<File> files = FileUtils.listFiles(testOutputFolder, new NameFileFilter("index.html"), TrueFileFilter.TRUE);
            if (files.isEmpty()) {
                return null;
            }
            File testIndexPage = files.iterator().next();
            return getRestfulUrl(testIndexPage.getPath().substring(testIndexPage.getPath().indexOf(TEST_OUTPUT_FOLDER)));
        }
    } catch (Exception ignore) {

    }
    return null;
}
 
开发者ID:gocd,项目名称:gocd,代码行数:18,代码来源:JobDetailPresentationModel.java

示例8: invokers

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
/**
 * Apply maven invoker settings.
 * @param builder Settings builder.
 * @param result User and global settings.
 * @return User, global and invoker settings.
 */
private Settings invokers(final SettingsBuilder builder,
    final SettingsBuildingResult result) {
    Settings main = result.getEffectiveSettings();
    final File[] files = new File(System.getProperty("user.dir"))
        .getParentFile().listFiles(
            (FileFilter) new NameFileFilter("interpolated-settings.xml")
    );
    if (files.length == 1) {
        final DefaultSettingsBuildingRequest irequest =
            new DefaultSettingsBuildingRequest();
        irequest.setUserSettingsFile(files[0]);
        try {
            final Settings isettings = builder.build(irequest)
                .getEffectiveSettings();
            SettingsUtils.merge(isettings, main, TrackableBase.USER_LEVEL);
            main = isettings;
        } catch (final SettingsBuildingException ex) {
            throw new IllegalStateException(ex);
        }
    }
    return main;
}
 
开发者ID:jcabi,项目名称:jcabi-aether,代码行数:29,代码来源:Aether.java

示例9: testScan

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
@Test
public void testScan() {
    File jarHome = new File(SystemUtils.JAVA_HOME);
    Set<File> directories = simpleFileScanner.scan(jarHome, true, DirectoryFileFilter.INSTANCE);
    Assert.assertFalse(directories.isEmpty());

    directories = simpleFileScanner.scan(jarHome, false, new NameFileFilter("bin"));
    Assert.assertEquals(1, directories.size());
}
 
开发者ID:mercyblitz,项目名称:confucius-commons,代码行数:10,代码来源:SimpleFileScannerTest.java

示例10: findReports

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
private List<String> findReports(String reportFileName)
        throws MojoFailureException {
    List<String> reportFiles = new ArrayList<>();

    NameFileFilter nameFileFilter = new NameFileFilter(reportFileName);
    Iterator<File> files = org.apache.commons.io.FileUtils
            .iterateFiles(getThreadFolder(),
                    nameFileFilter, DirectoryFileFilter.DIRECTORY);

    while(files.hasNext()) {
        reportFiles.add(files.next().getAbsolutePath());
    }

    return reportFiles;
}
 
开发者ID:eu-evops,项目名称:cucumber-runner-maven-plugin,代码行数:16,代码来源:Run.java

示例11: removeVltFiles

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
public static void removeVltFiles(String root) {
	for (File file : FileUtils.listFiles(new File(root), new NameFileFilter(".vlt"),
			TrueFileFilter.INSTANCE)) {
		LOG.info("Deleting {}", file.getPath());
		FileUtils.deleteQuietly(file);
	}
}
 
开发者ID:Cognifide,项目名称:Maven-Vault-Checkout-Plugin,代码行数:8,代码来源:CleanHelper.java

示例12: getFile

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
public static File getFile(File directory, String name) {
	List<File> files = list(directory, new NameFileFilter(name));
	
	if (files.size() == 1) {
		return files.get(0);
	} else {
		throw new IllegalArgumentException("Unable to find file " + name + " in " + directory.getAbsolutePath());
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:10,代码来源:FileUtils.java

示例13: getJavaSouceFile

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
private File getJavaSouceFile(FixtureDescription fixture, MetaInformation metaInformation, File fixtureSourceDirectory, String packageName) throws IOException {
    String fixtureFilename = fixture.getName() + JAVA_EXTENSION;
    File javaSouceFile = null;
    // we search in every imports
    List<String> imports = metaInformation.getImports();
    for (String anImport : imports) {
        File packageDir = new File(fixtureSourceDirectory, replaceChars(anImport, DOT, separatorChar));
        if (packageDir.isDirectory()) {
            Collection<File> files = listFiles(packageDir, new NameFileFilter(fixtureFilename, IOCase.INSENSITIVE), null);
            if (files.size() == 1) {
                javaSouceFile = files.iterator().next();
                break;
            } else if (files.size() > 1) {
                LOGGER.error("You have multiple java sources with the same case insensitive names.");
                LOGGER.error("We can't choose the file to merge the fixture in.");
                LOGGER.error("Moreover, your build is platform dependant because of this issue.");
                LOGGER.error("Incriminating files:");
                for (File file : files) {
                    LOGGER.error("\t - {}", file.getAbsolutePath());
                }
                break;
            }
        }
    }
    // if we didn't find the file
    if (javaSouceFile == null) {
        if (isNotBlank(packageName)) {
            File directoryForFixure = new File(fixtureSourceDirectory, replaceChars(packageName, DOT, separatorChar));
            forceMkdir(directoryForFixure);
            javaSouceFile = new File(directoryForFixure, fixtureFilename);
        } else {
            forceMkdir(fixtureSourceDirectory);
            javaSouceFile = new File(fixtureSourceDirectory, fixtureFilename);
            LOGGER.warn("You have no default package defined. I can't choose any import packages. Generating the Fixture in the source root. This is generally not a good idea.");
        }
    }
    return javaSouceFile ;
}
 
开发者ID:strator-dev,项目名称:greenpepper,代码行数:39,代码来源:JavaFixtureGenerator.java

示例14: locateZipalign

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
/**
 * Locates zipalign tool on disk.
 *
 * @return String
 */
public String locateZipalign() {
	String ext = isWindows() ? ".exe" : "";
	File zipalign = new File(FilenameUtils.normalize(sdkDirectory + "/tools/zipalign" + ext));
	if (zipalign.exists()) {
		return zipalign.getAbsolutePath();
	}

	// find any zipfiles under the sdk/build-tools
	Collection<File> files = FileUtils.listFiles(new File(sdkDirectory + "/build-tools"), new NameFileFilter("zipalign" + ext), TrueFileFilter.INSTANCE);
	if (files.size() > 0) {
		// found at least one zipalign file, look up the highest version
		Iterator<File> it = files.iterator();
		zipalign = it.next();
		while (it.hasNext()) {
			File f = it.next();
			if (zipalign.compareTo(f) < 0) {
				// f is newer
				zipalign = f;
			}
		}

		return zipalign.getAbsolutePath();
	}

	return null;
}
 
开发者ID:testfairy,项目名称:testfairy-uploader,代码行数:32,代码来源:SdkEnvironment.java

示例15: exportEtcDirectory

import org.apache.commons.io.filefilter.NameFileFilter; //导入依赖的package包/类
private void exportEtcDirectory(ExportSettings settings) {
    try {
        File targetBackupDir = new File(settings.getBaseDir(), "etc");
        // TODO: [by fsi] Find a way to copy with permissions kept
        FileUtils.copyDirectory(artifactoryHome.getEtcDir(), targetBackupDir,
                new NotFileFilter(new NameFileFilter("artifactory.lic")), true);
        checkSecurityFolder(targetBackupDir);
    } catch (IOException e) {
        settings.getStatusHolder().error(
                "Failed to export etc directory: " + artifactoryHome.getEtcDir().getAbsolutePath(), e, log);
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:13,代码来源:ArtifactoryApplicationContext.java


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