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


Java SuffixFileFilter类代码示例

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


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

示例1: findFilesToAnalyze

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
public static List<String> findFilesToAnalyze(String dirPath) {
	IOFileFilter gitFilter = FileFilterUtils.notFileFilter(
					FileFilterUtils.nameFileFilter(".git")
			);
	File dir = new File(dirPath);
	String[] phpExt = new String[] {"php"};
	IOFileFilter phpFilter = new SuffixFileFilter(phpExt, IOCase.INSENSITIVE);
	List<File> files = (List<File>) FileUtils.listFiles(dir, phpFilter, gitFilter);
	List<String> results = new ArrayList<String>();
	for (File f : files) {
		try {
			results.add(f.getCanonicalPath());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	return results;
}
 
开发者ID:wsdookadr,项目名称:mdetect,代码行数:20,代码来源:FileScanUtils.java

示例2: getFilePaths

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
/**
 * Get a list of file paths from the command line arguments.
 *
 * @param cmd Parsed command line arguments.
 * @return File[]
 */
public File[] getFilePaths(CommandLine cmd) {
  Collection<File> fileList = new ArrayList<>();

  List<?> argList = cmd.getArgList();
  argList = argList.subList(1, argList.size());
  String[] args = argList.toArray(new String[argList.size()]);

  if (argList.isEmpty()) {
    File dir = new File("input");
    SuffixFileFilter sfx = new SuffixFileFilter(".txt");
    fileList = FileUtils.listFiles(dir, sfx, TrueFileFilter.INSTANCE);
  } else {
    for (String name : args) {
      fileList.add(new File(name));
    }
  }

  File[] files = fileList.toArray(new File[fileList.size()]);
  Arrays.sort(files);
  return files;
}
 
开发者ID:ubermichael,项目名称:isetools,代码行数:28,代码来源:Command.java

示例3: loadPlugins

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
/**
 * When the server starts up it will reload all the plugins back in
 * @throws IOException
 */
@PostConstruct
public void loadPlugins() throws IOException {
    File pluginsDir = new File(config.getPluginDir());
    if (!pluginsDir.exists()) {
        pluginsDir.mkdirs();
    }
    if (pluginsDir.exists()) {
        FilenameFilter jarSuffix = new SuffixFileFilter(".jar");
        File[] files = pluginsDir.listFiles(jarSuffix);
        for (File file : files) {
            storePlugin(file);
        }
    } else {
        LOGGER.warn("Plugins directory does not exist '" + pluginsDir.getAbsolutePath() + "'");
    }
}
 
开发者ID:Comcast,项目名称:dawg,代码行数:21,代码来源:RemotePluginManager.java

示例4: testNoDescriptorsInSrc

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
public static void testNoDescriptorsInSrc(String srcDirectoryName) {
  // collect the names of all .xml descriptors in the src directory
  File srcDirectory = new File(srcDirectoryName);
  Set<String> descNames = new HashSet<String>();
  Iterator<?> files = org.apache.commons.io.FileUtils.iterateFiles(
      srcDirectory,
      new SuffixFileFilter(".xml"),
      TrueFileFilter.INSTANCE);
  while (files.hasNext()) {
    File file = (File) files.next();
    descNames.add(file.getPath());
  }

  if (descNames.size() > 0) {
    String message = String.format("%d descriptors in src/main/java", descNames.size());
    System.err.println(message);
    List<String> sortedFileNames = new ArrayList<String>(descNames);
    Collections.sort(sortedFileNames);
    for (String name : sortedFileNames) {
      System.err.println(name);
    }
    Assert.fail(message);
  }

}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:26,代码来源:DescriptorTestUtil.java

示例5: findExternalBundles

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
/**
 * Find external/optional bundles from the ~/.motech/bundles directory.
 * Additional modules come from that directory, additionally platform bundles
 * can be override,
 */
private Map<BundleID, URL> findExternalBundles() throws IOException {
    Map<BundleID, URL> externalBundles = new HashMap<>();
    if (StringUtils.isNotBlank(externalBundleFolder)) {
        File folder = new File(externalBundleFolder);
        boolean exists = folder.exists();

        if (!exists) {
            exists = folder.mkdirs();
        }

        if (exists) {
            File[] files = folder.listFiles((FileFilter) new SuffixFileFilter(".jar"));
            URL[] urls = FileUtils.toURLs(files);

            for (URL url : urls) {
                BundleID bundleID = bundleIdFromURL(url);
                if (bundleID != null) {
                    externalBundles.put(bundleID, url);
                }
            }
        }
    }

    return externalBundles;
}
 
开发者ID:motech,项目名称:motech,代码行数:31,代码来源:OsgiFrameworkService.java

示例6: test

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
@Test
public void test() throws IOException {
	List<String> imageSuffixes = Lists.newArrayList();
	for (ImageInfo.Format format : ImageInfo.Format.values()) {
		for (String ext : format.getCommonExtensions()) {
			imageSuffixes.add("." + ext);
		}
	}
	SuffixFileFilter filter = new SuffixFileFilter(imageSuffixes);
	List<File> files = TestData.getFiles(filter);
	for (File file : files) {
		byte[] bytes = Files.toByteArray(file);
		BytePair magic = MagicNumbers.read(bytes);
		System.out.format("%s %s%n", magic, file.getName());
	}
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:17,代码来源:MagicNumbersTest.java

示例7: extractFileUserIdentifiers

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
/**
 * Return set of file user identifiers from a list of files
 * 
 * @param user user who uploaded or will upload file
 * @param files list of files objects
 * @return Set containing all user identifiers from list of files
 * 
 * @see org.kuali.kfs.sys.batch.BatchInputFileSetType#extractFileUserIdentifiers(org.kuali.rice.kim.api.identity.Person, java.util.List)
 */
public Set<String> extractFileUserIdentifiers(Person user, List<File> files) {
    Set<String> extractedFileUserIdentifiers = new TreeSet<String>();

    StringBuilder buf = new StringBuilder();
    buf.append(FILE_NAME_PREFIX).append(FILE_NAME_PART_DELIMITER).append(user.getPrincipalName()).append(FILE_NAME_PART_DELIMITER);
    String prefixString = buf.toString();

    IOFileFilter prefixFilter = new PrefixFileFilter(prefixString);
    IOFileFilter suffixFilter = new SuffixFileFilter(CamsConstants.BarCodeInventory.DATA_FILE_EXTENSION);
    IOFileFilter combinedFilter = new AndFileFilter(prefixFilter, suffixFilter);

    for (File file : files) {
        if (combinedFilter.accept(file)) {
            String fileName = file.getName();
            if (fileName.endsWith(CamsConstants.BarCodeInventory.DATA_FILE_EXTENSION)) {
                extractedFileUserIdentifiers.add(StringUtils.substringBetween(fileName, prefixString, CamsConstants.BarCodeInventory.DATA_FILE_EXTENSION));
            } else {
                LOG.error("Unable to determine file user identifier for file name: " + fileName);
                throw new RuntimeException("Unable to determine file user identifier for file name: " + fileName);
            }
        }
    }

    return extractedFileUserIdentifiers;
}
 
开发者ID:kuali,项目名称:kfs,代码行数:35,代码来源:AssetBarcodeInventoryInputFileType.java

示例8: VFSManager

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
public VFSManager(File systemDir, File userDir) {
    super(systemDir, userDir, new SuffixFileFilter(".xml", IOCase.INSENSITIVE));

    Comparator<File> nameComparator = new Comparator<File>() {
        @Override
        public int compare(File f1, File f2) {
            // we want vfs.xml to loaded first, always.
            if (f1.getName().equals("x-vfs.xml"))
                return Integer.MIN_VALUE;
            if (f2.getName().equals("x-vfs.xml"))
                return Integer.MAX_VALUE;
            return f1.getName().compareToIgnoreCase(f2.getName());
        }
    };

    getSystemFiles().setNameComparator(nameComparator);
}
 
开发者ID:stuckless,项目名称:sagetv-phoenix-core,代码行数:18,代码来源:VFSManager.java

示例9: DynamicClassLoader

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
public DynamicClassLoader() {
	try {
		File home = new File(System.getProperty("user.home"), "netxilia");
		if (!home.exists()) {
			if (!home.mkdir()) {
				log.error("Could not create Netxilia storage directory:" + home);
				return;
			}
		}
		addFile(home);
		for (File jar : home.listFiles((FilenameFilter) new SuffixFileFilter(".jar"))) {
			addFile(jar);
		}
	} catch (IOException e) {
		log.error("ERROR:" + e);
	}

}
 
开发者ID:netxilia,项目名称:netxilia,代码行数:19,代码来源:DynamicClassLoader.java

示例10: AutoCompletionManager

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
public AutoCompletionManager(Config config) throws SearchLibException,
		IOException {
	this.config = config;
	autoCompletionDirectory = new File(config.getDirectory(),
			autoCompletionSubDirectory);
	if (!autoCompletionDirectory.exists())
		autoCompletionDirectory.mkdir();
	autoCompItems = new TreeSet<AutoCompletionItem>();
	File[] autoCompFiles = autoCompletionDirectory
			.listFiles((FileFilter) new SuffixFileFilter(".xml"));
	if (autoCompFiles == null)
		return;
	for (File autoCompFile : autoCompFiles) {
		try {
			add(new AutoCompletionItem(config, autoCompFile));
		} catch (InvalidPropertiesFormatException e) {
			Logging.warn("Invalid autocompletion file: "
					+ autoCompFile.getAbsolutePath());
		}
	}
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:22,代码来源:AutoCompletionManager.java

示例11: calculateNextSequence

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
/**
 * Calculate the next sequence used to generate the db-changelog file.
 *
 * The sequence is formatted as follow:
 *    leftpad with 0 + number
 * @return the next sequence
 */
private String calculateNextSequence() {
    final File changeLogFolder = FileSystems.getDefault().getPath(CHANGELOG_FOLER).toFile();

    final File[] allChangelogs = changeLogFolder.listFiles((FileFilter) new SuffixFileFilter(".xml"));

    Integer sequence = 0;

    for (File changelog : allChangelogs) {
        String fileName = FilenameUtils.getBaseName(changelog.getName());
        String currentSequence = StringUtils.substringAfterLast(fileName, "-");
        int cpt = Integer.parseInt(currentSequence);
        if (cpt > sequence) {
            sequence = cpt;
        }
    }
    sequence++;
    return StringUtils.leftPad(sequence.toString(), 3, "0");
}
 
开发者ID:exteso,项目名称:parkingfriends,代码行数:26,代码来源:LiquibaseReloader.java

示例12: scanDirectoriesAtFolderChosen

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
/**
 * Scans sub directories associated with the target 'src' folder, lists them into dirsList
 * @throws IOException 
 * 
 */
public static synchronized void scanDirectoriesAtFolderChosen(JFileChooser jfc, Path dir, ConcurrentHashMap<String, String> holdValueToKey, WatchService watcher) throws IOException{//JFileChooser jfc, Path dir
	File f = new File(jfc.getSelectedFile().getAbsolutePath());
	if(f.isDirectory()){
	//System.out.println("Is a directory: "+jfc.getSelectedFile().getAbsolutePath());

	File rFile = new File(jfc.getSelectedFile().getAbsolutePath());
	SuffixFileFilter extFilter = new SuffixFileFilter("java");
	Collection filesListUtil = FileUtils.listFilesAndDirs(rFile,extFilter,TrueFileFilter.INSTANCE); //get utils for files in subdir, looks for .java files as well
	ArrayList<File> filesList = new ArrayList<File>();
	ArrayList<File> dirsList = new ArrayList<File>();

	for(java.util.Iterator fileIter = filesListUtil.iterator();fileIter.hasNext();){	//iterate through filesListUtil subdirs, add to filesList to be watched
		File currentF = (File) fileIter.next();
		//System.out.println("Reading Paths from: "+currentF.getAbsolutePath());
		if(!(currentF.isDirectory())){
			filesList.add(currentF);	//add each file while iterating through subdirectories
		}else{
			dirsList.add(currentF);	//add each dir to watch
		}
	}


	/**
 	* File system traversal
 	*/

	System.out.println("WatchService: DirectoriesList length = "+dirsList.size());
	//System.out.println("FilesListUtil length: "+filesListUtil.size());
	fileSystemTraversal(dirsList, dir, watcher, holdValueToKey);
	
	}
}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:38,代码来源:AgendaPanel.java

示例13: findClassNamesInDirectory

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
protected static Set<String> findClassNamesInDirectory(File classesDirectory, boolean recursive) {
    Set<String> classNames = Sets.newLinkedHashSet();
    SimpleFileScanner simpleFileScanner = SimpleFileScanner.INSTANCE;
    Set<File> classFiles = simpleFileScanner.scan(classesDirectory, recursive, new SuffixFileFilter(FileSuffixConstants.CLASS));
    for (File classFile : classFiles) {
        String className = resolveClassName(classesDirectory, classFile);
        classNames.add(className);
    }
    return classNames;
}
 
开发者ID:mercyblitz,项目名称:confucius-commons,代码行数:11,代码来源:ClassUtils.java

示例14: setupExternalFileOutput

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
public static void setupExternalFileOutput() {
    try {
        Date currentDate = new Date();
        long currentTime = currentDate.getTime();
        String fileName = new SimpleDateFormat("yyMMddhhmm").format(currentDate) + ".log";
        File logFile = new File(LwjglFiles.externalPath + AppConstants.LOGS_DIR + File.separator + fileName);
        logFile.getParentFile().mkdirs();
        for (File oldLogFile : logFile.getParentFile().listFiles((FileFilter)new SuffixFileFilter(LOG_FILE_EXTENSION))) {
            long lastModified = oldLogFile.lastModified();
            if (currentTime - lastModified > EXPIRATION_THRESHOLD) {
                try { oldLogFile.delete(); } catch (SecurityException ignored) { }
            }
        }
        FileOutputStream logFileOutputStream = new FileOutputStream(logFile);
        System.setOut(new PrintStream(new OutputStreamMultiplexer(
                new FileOutputStream(FileDescriptor.out),
                logFileOutputStream
        )));
        System.setErr(new PrintStream(new OutputStreamMultiplexer(
                new FileOutputStream(FileDescriptor.err),
                logFileOutputStream
        )));
        System.out.println("Version: " + AppConstants.version);
        System.out.println("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch"));
        System.out.println("JRE: " + System.getProperty("java.version") + " " + System.getProperty("java.vendor"));
        System.out.println("External log file: " + logFile.getAbsolutePath());
    } catch (FileNotFoundException e) {
        System.err.println("Can't setup logging to external file.");
        e.printStackTrace();
    }
}
 
开发者ID:crashinvaders,项目名称:gdx-texture-packer-gui,代码行数:32,代码来源:LoggerUtils.java

示例15: getOsgiBootstrapClasspath

import org.apache.commons.io.filefilter.SuffixFileFilter; //导入依赖的package包/类
public static List<File> getOsgiBootstrapClasspath(File engineDirectory)
{
  if (engineDirectory == null || !engineDirectory.isDirectory())
  {
    return Collections.emptyList();
  }
  List<File> classPathFiles = new ArrayList<>();
  addToClassPath(classPathFiles, new File(engineDirectory, OsgiDir.INSTALL_AREA + "/" + OsgiDir.LIB_BOOT), new SuffixFileFilter(".jar"));
  return classPathFiles;
}
 
开发者ID:axonivy,项目名称:project-build-plugin,代码行数:11,代码来源:EngineClassLoaderFactory.java


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