Java Code Examples for

The following examples show how to use 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
	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());
	return files;
Example 2
Source Project: singer   Source File:    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))

Example 4
Source Project: oxTrust   Source File:    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)) {

		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) {

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

	return logFiles;
Example 5
Source Project: incubator-gobblin   Source File:    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:    License: MIT License 2 votes vote down vote up
 * @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);