Java 类org.apache.commons.io.filefilter.FileFileFilter 实例源码

项目:lams    文件:AbstractLocalFileSystemConnector.java   
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;
}
项目:AGIA    文件:AbstractFileOperations.java   
protected void copyFile(Resource sOriginFile, Resource sDestinationFile) throws IOException {
    File aOrigineFile = sOriginFile.getFile();
    if (aOrigineFile.isFile()) {
        if (!isDirectory(sDestinationFile)) {
            FileUtils.copyFile(aOrigineFile, sDestinationFile.getFile(), preserveAttributes);
        } else {
            FileUtils.copyFileToDirectory(aOrigineFile, sDestinationFile.getFile(), preserveAttributes);
        }
    } else {
        if (recursive) {
            FileUtils.copyDirectory(aOrigineFile, sDestinationFile.getFile(), preserveAttributes);
        } else {
            FileUtils.copyDirectory(aOrigineFile, sDestinationFile.getFile(), FileFileFilter.FILE, preserveAttributes);
        }
    }
}
项目:azkaban-plugins    文件:FileUtils.java   
/**
 * Find files while input can use wildcard * or ?
 *
 * @param filesStr File path(s) delimited by delimiter
 * @param delimiter Separator of file paths.
 * @return List of absolute path of files
 */
public static Collection<String> listFiles(String filesStr, String delimiter) {
  ValidationUtils.validateNotEmpty(filesStr, "fileStr");

  List<String> files = new ArrayList<String>();
  for (String s : filesStr.split(delimiter)) {
    File f = new File(s);
    if (!f.getName().contains("*") && !f.getName().contains("?")) {
      files.add(f.getAbsolutePath());
      continue;
    }

    FileFilter fileFilter = new AndFileFilter(new WildcardFileFilter(f.getName()), FileFileFilter.FILE);
    File parent = f.getParentFile() == null ? f : f.getParentFile();
    File[] filteredFiles = parent.listFiles(fileFilter);
    if(filteredFiles == null) {
      continue;
    }

    for (File file : filteredFiles) {
      files.add(file.getAbsolutePath());
    }
  }
  return files;
}
项目:ocms    文件:XmlResponse.java   
public void setFiles(File dir) {

    if (filesElement != null) {
        Element parent = (Element) filesElement.getParentNode();
        parent.removeChild(filesElement);
    }

    filesElement = document.createElement("Files");
    document.getDocumentElement().appendChild(filesElement);

    File[] fileList = dir.listFiles((FileFilter) FileFileFilter.FILE);
    long length;
    for (File file : fileList) {
        Element fileElement = document.createElement("File");
        fileElement.setAttribute("name", file.getName());
        if (file.length() < 1024)
            length = 1L;
        else 
            length = file.length()/1024;
        fileElement.setAttribute("size", String.valueOf(length));
        filesElement.appendChild(fileElement);
    }
}
项目:JumperSumo    文件:Daemon.java   
/**
 * This method is called when invoke <b>execute()</b>.<br />
 * Do not invoke manually. Use: <i>new Daemon().execute("");</i>
 *
 * @param params blank string.
 * @return null if all is going ok.
 */
@Override
protected String doInBackground(String... params) {

    while (folder.listFiles().length > 0)
    {
        // Select only files, no directory.
        File[] files = folder.listFiles((FileFilter) FileFileFilter.FILE);
        // Sorting following FIFO idea.
        Arrays.sort(files, LastModifiedFileComparator.LASTMODIFIED_REVERSE);

        if (files[0].getName().endsWith(".csv") || files[0].getName().endsWith(".txt")) {
            String commandsList = "";
            try {
                commandsList = f.getStringFromFile(files[0].getPath());
            } catch (Exception e) {
                e.printStackTrace();
            }
            Log.e(TAG, "Lista comandi: " + commandsList);
            Interpreter in = new Interpreter(deviceController);
            in.doListCommands(commandsList);
            files[0].delete();
        } else {
            Log.e(TAG, "Error: There is no csv|txt files or is not a file but a directory.");
        }
    }
    return null;
}
项目:gluu    文件:ViewLogFileAction.java   
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;
}
项目:awake-file    文件:FileSession.java   
/**
    * get the list of files or directories in a directory
    * 
    * @param pathname
    *            the directory pathname to list
    * @param type
    *            the type of File list to return: LIST_FILES_ONLY or
    *            LIST_DIRECTORIES_ONLY
    * @return the files or directories list
    * 
    * @throws InvalidLoginException
    */
   private List<String> listFilesOrDirectories(String pathname, int type)
    throws InvalidLoginException {

pathname = PathUtil.rewriteToUnixSyntax(pathname);

RemoteFile theRemoteFile = new RemoteFile(remoteSession, pathname);

FileFilter fileFilter = null;

if (type == LIST_FILES_ONLY) {
    fileFilter = FileFileFilter.FILE;
} else if (type == LIST_DIRECTORIES_ONLY) {
    fileFilter = DirectoryFileFilter.DIRECTORY;
} else {
    throw new IllegalArgumentException(
        Tag.PRODUCT_PRODUCT_FAIL
            + " Invalid type. Msust be LIST_FILES_ONLY or LIST_DIRECTORIES_ONLY. Is: "
            + type);
}

RemoteFile[] remoteFiles = theRemoteFile.listFiles(fileFilter);

if (remoteFiles == null) {
    return null;
}

List<String> filenameList = new ArrayList<String>();
for (RemoteFile remoteFileItem : remoteFiles) {
    filenameList.add(remoteFileItem.getName());
}

return filenameList;
   }
项目:Pinot    文件:TestStarTreeStats.java   
@Test
public void testList(){
  Collection<File> listFiles = FileUtils.listFiles(new File("."), FileFileFilter.FILE, DirectoryFileFilter.DIRECTORY);
  for(File f: listFiles){
    System.out.println(f.getAbsolutePath());
  }
  UUID orig = UUID.randomUUID();
  System.out.println(orig);
  byte bytes[] = orig.toString().getBytes();
  System.out.println(new String(bytes));
  UUID temp = UUID.fromString("4c200d28-2c3d-4a6b-aecb-57ba8715be1d");
  Long.parseLong("57ba8715be1d", 16);
  System.out.println(temp);
}
项目:oxTrust    文件:ViewLogFileAction.java   
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;
}
项目:incubator-gobblin    文件:GobblinAWSUtils.java   
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));
}
项目:AGIA    文件:ZipFilesTasklet.java   
protected void zipResource(Resource sSourceResource, ZipArchiveOutputStream sZipArchiveOutputStream, StepContribution sContribution, ChunkContext sChunkContext) throws IOException, ZipFilesException {
    // TODO : use a queue to reduce the callstack overhead
    if (sSourceResource.exists()) {
        File aSourceFile = sSourceResource.getFile();
        String aSourcePath = aSourceFile.getCanonicalPath();

        if (!aSourcePath.startsWith(sourceBaseDirectoryPath)) {
            throw new ZipFilesException("Source file " + aSourcePath + " does not match base directory " + sourceBaseDirectoryPath);
        }

        if (sContribution != null) {
            sContribution.incrementReadCount();
        }
        String aZipEntryName = aSourcePath.substring(sourceBaseDirectoryPath.length() + 1);
        sZipArchiveOutputStream.putArchiveEntry(new ZipArchiveEntry(aZipEntryName));
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("Zipping {} to {}", sSourceResource.getFile().getCanonicalPath(), aZipEntryName);
        }
        if (aSourceFile.isFile()) {
            InputStream aInputStream = sSourceResource.getInputStream();
            IOUtils.copy(aInputStream, sZipArchiveOutputStream);
            aInputStream.close();
            sZipArchiveOutputStream.closeArchiveEntry();
        } else {
            sZipArchiveOutputStream.closeArchiveEntry();
            for(File aFile : aSourceFile.listFiles((FileFilter)(recursive ? TrueFileFilter.TRUE : FileFileFilter.FILE))) {
                zipResource(new FileSystemResource(aFile), sZipArchiveOutputStream, sContribution, sChunkContext);
            }
        }
        if (sContribution != null) {
            sContribution.incrementWriteCount(1);
        }
    } else if (LOGGER.isInfoEnabled()) {
            LOGGER.info("{} does not exist", sSourceResource.getFilename());
    }
}
项目:opensearchserver    文件:RestCrawlThread.java   
private int runFiles(RestCrawlContext context, URI uri) throws Exception {
    File rootFile = new File(uri);
    if (rootFile.isFile())
        return runFile(context, rootFile);
    int res = 0;
    for (File file : rootFile.listFiles((FileFilter) FileFileFilter.FILE))
        res += runFile(context, file);
    return res;
}
项目:sagetv-phoenix-core    文件:TestMediaResources.java   
@Test
public void testMediaScan() {
    makeFile("test/movies/dira/Nemo.avi");
    makeFile("test/movies/dira/Nemo.avi.properties");
    makeFile("test/movies/dira/Nemo.jpg");
    makeFile("test/movies/dira/Terminator.avi");
    makeFile("test/movies/dirb/x.avi");
    makeFile("test/movies/dirc/y/VIDEO_TS/test.vob");
    makeFile("test/movies/dirc/y/VIDEO_TS/test.buf");
    makeFile("test/movies/dird/dire/z.avi");
    makeFile("test/movies/dire/BDMV/test.m2ts");
    makeFile("test/movies/merlin/video.vob");

    final List<IMediaResource> files = new ArrayList<IMediaResource>();
    IMediaResourceVisitor vis = new IMediaResourceVisitor() {
        @Override
        public boolean visit(IMediaResource res, IProgressMonitor monitor) {
            if (res.isType(MediaResourceType.ANY_VIDEO.value())) {
                files.add(res);
            }
            return true;
        }
    };

    IMediaFolder mf = FileResourceFactory.createFolder(makeDir("test/movies"));
    mf.accept(vis, null, IMediaResource.DEEP_UNLIMITED);
    assertEquals("visitor failed", 7, files.size());
    assertEquals("children", 6, mf.getChildren().size());

    int fileCtr = 0, dirs = 0;
    for (IMediaResource r : mf.getChildren()) {
        if (r instanceof IMediaFile) {
            fileCtr++;
        } else {
            dirs++;
        }
    }

    assertEquals("files", 2, fileCtr);
    assertEquals("folders", 4, dirs);

    // media folder delete will delete everything...
    mf.delete(null);
    assertEquals("delete()", false, mf.exists());

    final List filesLeft = new LinkedList();
    sagex.phoenix.util.DirectoryScanner scanner = new DirectoryScanner(FileFileFilter.FILE);
    scanner.scan(makeDir("test/movies"), filesLeft);

    assertEquals("files left", 0, filesLeft.size());
}
项目:newspaper-batch-event-framework    文件:SimpleIteratorForFilesystems.java   
@Override
protected Iterator<File> initilizeAttributeIterator() {
    List<File> attributes = new ArrayList<>(FileUtils.listFiles(id, FileFileFilter.FILE, null));
    Collections.sort(attributes);
    return attributes.iterator();
}
项目:project-cec-2013    文件:FolderDaoImpl.java   
/**
 * It returns only the file names under a given directory specified by argument 
 * dir.
 *
 * @param dir the dir
 * @return the file names
 */
protected static String[] getFileNames(String dir) {
    File folder = new File(dir);
    String[] xmlFiles = folder.list(FileFileFilter.FILE);
    return xmlFiles;
}