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

The following examples show how to use org.apache.commons.io.filefilter.FileFileFilter. 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
Source File: AbstractLocalFileSystemConnector.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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 File: LogDirectoriesScanner.java    From singer with 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
Source File: FileTools.java    From MtgDesktopCompanion with GNU General Public License v3.0 5 votes vote down vote up
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 File: ViewLogFileAction.java    From oxTrust with 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 File: GobblinAWSUtils.java    From incubator-gobblin with 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 File: TacFileService.java    From tac with 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);
}