Java Code Examples for org.apache.commons.io.filefilter.FileFileFilter

The following examples show how to use org.apache.commons.io.filefilter.FileFileFilter. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public List<Map<String, Object>> getFiles(ResourceType type,
		String currentFolder) throws InvalidCurrentFolderException {
	String absolutePath = getRealUserFilesAbsolutePath(RequestCycleHandler
			.getUserFilesAbsolutePath(ThreadLocalData.getRequest()));
	File typeDir = getOrCreateResourceTypeDir(absolutePath, type);
	File currentDir = new File(typeDir, currentFolder);
	if (!currentDir.exists() || !currentDir.isDirectory())
		throw new InvalidCurrentFolderException();

	// collect files
	List<Map<String, Object>> files;
	Map<String, Object> fileMap;
	File[] fileList = currentDir
			.listFiles((FileFilter) FileFileFilter.FILE);
	files = new ArrayList<Map<String, Object>>(fileList.length);
	for (File file : fileList) {
		fileMap = new HashMap<String, Object>(2);
		fileMap.put(Connector.KEY_NAME, file.getName());
		fileMap.put(Connector.KEY_SIZE, file.length());
		files.add(fileMap);
	}
	return files;
}
 
Example 2
Source Project: singer   Source File: LogDirectoriesScanner.java    License: Apache License 2.0 5 votes vote down vote up
public List<File> getFilesInSortedOrder(Path dirPath) {
  File[] files = dirPath.toFile().listFiles((FileFilter) FileFileFilter.FILE);

  // Sort the file first by last_modified timestamp and then by name in case two files have
  // the same mtime due to precision (mtime is up to seconds).
  Ordering<File> ordering = Ordering.from(new SingerUtils.LogFileComparator());
  List<File> logFiles = ordering.sortedCopy(Arrays.asList(files));
  return logFiles;
}
 
Example 3
public static void extractConfig(File fzip) throws IOException 
{
	IOFileFilter fileFilter1 =   FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("logs", null));
	IOFileFilter fileFilter2 =   FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("data", null));
	IOFileFilter exceptFilter =   FileFilterUtils.and(fileFilter1, fileFilter2 );
	
	
	try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(fzip))) {
		for(File f : FileUtils.listFilesAndDirs(MTGConstants.CONF_DIR, FileFileFilter.FILE, exceptFilter))
			addFile(f,out);
	}

}
 
Example 4
Source Project: oxTrust   Source File: ViewLogFileAction.java    License: MIT License 5 votes vote down vote up
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;
}
 
Example 5
Source Project: incubator-gobblin   Source File: GobblinAWSUtils.java    License: Apache License 2.0 5 votes vote down vote up
private static String getClasspathFromPath(File path) {
  if (null == path) {
    return StringUtils.EMPTY;
  }
  if (!path.isDirectory()) {
    return path.getAbsolutePath();
  }

  return Joiner.on(":").skipNulls().join(path.list(FileFileFilter.FILE));
}
 
Example 6
Source Project: tac   Source File: TacFileService.java    License: MIT License 2 votes vote down vote up
/**
 *listAllFiles
 *
 * @param directory
 * @return List
 */
public static List<File> listAllFiles(File directory) {
    Collection<File> files = FileUtils.listFiles(directory, FileFileFilter.FILE, DirectoryFileFilter.DIRECTORY);
    return Lists.newArrayList(files);
}