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

项目:mtgo-best-bot    文件:ProcessManager.java   
private String getExecutable() {
    File supposedExecutable = new File(executableDir + executableName);

    if(supposedExecutable.exists()) {
        return supposedExecutable.getAbsolutePath();
    } else {
        Collection<File> theExecutable = FileUtils.listFiles(new File(executableDir), new WildcardFileFilter(executableName), TrueFileFilter.INSTANCE);

        if(theExecutable != null || theExecutable.size() > 1 || theExecutable.isEmpty()) {
            File newestExecutable = theExecutable.stream().reduce(new File(""),
                    (aFile, newestFile) -> {
                        if(aFile.lastModified() > newestFile.lastModified()) {
                            return aFile;
                        }

                        return newestFile;
                    });

            return newestExecutable.getAbsolutePath();
        } else if(theExecutable.size() == 1) {
            return ((File)CollectionUtils.get(theExecutable, 0)).getAbsolutePath();
        } else {
            throw new RuntimeException("Could not determine executable path");
        }
    }
}
项目:rest-modeling-framework    文件:MdGenerator.java   
@Override
public void generate(Api api, File outputPath) throws IOException {
    if (outputPath.exists()) {
        Collection<File> files = FileUtils.listFiles(
                outputPath,
                TrueFileFilter.INSTANCE,
                TrueFileFilter.INSTANCE
        );
        for (File file : files) {
            if (file.isFile()) {
                Files.deleteIfExists(file.toPath());
            }
        }
    } else {
        Files.createDirectories(outputPath.toPath());
    }

    TypesGenerator generator = new TypesGenerator();
    generator.generate(api.getTypes(), new File(outputPath, "types") );

}
项目:atlas    文件:NativeSoUtils.java   
/**
 * Verify the directory of the so file under the abi
 *
 * @param supportAbis
 * @param removeSoFiles
 * @param dirs
 * @return
 */
public static Map<String, Multimap<String, File>> getAbiSoFiles(Set<String> supportAbis, Set<String> removeSoFiles,
                                                                List<File> dirs) {
    Map<String, Multimap<String, File>> result = new HashMap<String, Multimap<String, File>>();
    IOFileFilter filter = new NativeSoFilter(supportAbis, removeSoFiles);
    for (File dir : dirs) {
        Collection<File> files = FileUtils.listFiles(dir, filter, TrueFileFilter.TRUE);
        for (File file : files) {
            File parentFolder = file.getParentFile();
            String parentName = parentFolder.getName();
            String shortName = getSoShortName(file);
            Multimap<String, File> maps = result.get(parentName);
            if (null == maps) {
                maps = HashMultimap.create(10, 3);
            }
            maps.put(shortName, file);
            result.put(parentName, maps);
        }

    }
    return result;
}
项目:atlas    文件:ApkFileListUtils.java   
/**
 * Initializes the file list information for the apk file
 *
 * @return
 */
protected static void prepareApkFileList(File folder, String prefixName, ApkFiles apkFiles) {
    if (!folder.exists()) {
        return;
    }
    // Gets information about the main bundle
    Collection<File> files = FileUtils.listFiles(folder, new PureFileFilter(), TrueFileFilter.INSTANCE);
    for (File file : files) {
        if (file.isFile()) {
            String relativePath = prefixName + File.separator + PathUtil.toRelative(folder, file.getAbsolutePath());
            String md5 = MD5Util.getFileMD5(file);
            if (isImageFile(relativePath)) {
                apkFiles.apkFileList.put(relativePath, md5);
            }
            apkFiles.finalApkFileList.put(relativePath, md5);
        }
    }

}
项目:atlas    文件:ApkFileListUtils.java   
protected static void prepareApkFileList(File folder, String prefixName, String awbName, ApkFiles apkFiles) {
    if (!folder.exists()) {
        return;
    }
    // Gets information about the main bundle
    Collection<File> files = FileUtils.listFiles(folder, new PureFileFilter(), TrueFileFilter.INSTANCE);
    for (File file : files) {
        if (file.isFile()) {
            String relativePath = prefixName + File.separator + PathUtil.toRelative(folder, file.getAbsolutePath());
            String md5 = MD5Util.getFileMD5(file);
            if (isImageFile(relativePath)) {
                if (null == apkFiles.apkFileList.getAwbs().get(awbName)) {
                    apkFiles.apkFileList.getAwbs().put(awbName, new HashMap<String, String>());
                }
                apkFiles.apkFileList.getAwbs().get(awbName).put(relativePath, md5);
            }
            if (null == apkFiles.finalApkFileList.getAwbs().get(awbName)) {
                apkFiles.finalApkFileList.getAwbs().put(awbName, new HashMap<String, String>());
            }
            apkFiles.finalApkFileList.getAwbs().get(awbName).put(relativePath, md5);
        }
    }

}
项目:atlas    文件:TPatchTool.java   
private File createTPatchFile(File outPatchDir, File patchTmpDir) throws IOException {
    // 首先压缩主bundle,先判断主bundle里有没有文件
    File mainBundleFoder = new File(patchTmpDir, ((TpatchInput)input).mainBundleName);
    File mainBundleFile = new File(patchTmpDir, ((TpatchInput)input).mainBundleName + ".so");
    if (FileUtils.listFiles(mainBundleFoder, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)
        .size() > 0) {
        hasMainBundle = true;
        CommandUtils.exec(mainBundleFoder, "zip -r " + mainBundleFile.getAbsolutePath() + " . -x */ -x .*");
    }
    FileUtils.deleteDirectory(mainBundleFoder);

    // 再压缩各自的bundle
    File patchFile = null;

        patchFile = new File(outPatchDir,
                "patch-" + input.newApkBo.getVersionName() + "@" + input.baseApkBo.getVersionName() + ".tpatch");
    if (patchFile.exists()) {
        FileUtils.deleteQuietly(patchFile);
    }
    //        zipBundle(patchTmpDir, patchFile);
    CommandUtils.exec(patchTmpDir, "zip -r " + patchFile.getAbsolutePath() + " . -x */ -x .*");
    FileUtils.deleteDirectory(patchTmpDir);
    return patchFile;
}
项目:atlas    文件:PatchFileBuilder.java   
/**
 * 将指定文件夹下的文件转换为map
 *
 * @param folder
 * @return
 * @throws PatchException
 */
private Map<String, FileDef> getListFileMap(File folder) throws PatchException, IOException {
    Map<String, FileDef> map = new HashMap<String, FileDef>();
    if (!folder.exists() || !folder.isDirectory()) {
        throw new PatchException("The input folder:" + folder.getAbsolutePath()
                                     + " does not existed or is not a directory!");
    }
    Collection<File> files = FileUtils.listFiles(folder, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
    for (File file : files) {
        String path = PathUtils.toRelative(folder, file.getAbsolutePath());
        String md5 = MD5Util.getFileMD5String(file);
        FileDef fileDef = new FileDef(md5, path, file);
        map.put(path, fileDef);
    }
    return map;
}
项目:convertigo-engine    文件:MobileResourceHelper.java   
public void listFiles(JSONObject response) throws JSONException, IOException {
    File canonicalDir = destDir.getCanonicalFile();
    int uriDirectoryLength = canonicalDir.toURI().toString().length();
    JSONArray jArray = new JSONArray();

    for (File f : FileUtils.listFiles(canonicalDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) {
        File canonnicalF = f.getCanonicalFile();
        JSONObject jObj = new JSONObject();
        jObj.put("uri", URLDecoder.decode(canonnicalF.toURI().toString().substring(uriDirectoryLength), "UTF-8"));
        jObj.put("date", canonnicalF.lastModified());
        jObj.put("size", canonnicalF.length());
        jArray.put(jObj);
    }
    response.put("files", jArray);
    response.put("date", destDir.lastModified());
}
项目:momo-2    文件:CommandHandler.java   
/**
 * Normalize all guild commands
 * @param collection All commands
 * @throws ConfigurationException If apache config throws an exception
 */
private static void normalizeCommands(Collection<Command> collection) throws ConfigurationException {
    Collection<File> found = FileUtils.listFiles(new File("resources/guilds"),
            TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
    found.add(new File("resources/guilds/template.properties"));
    for (File f : found) {
        if (f.getName().equals("GuildProperties.properties") || f.getName().equals("template.properties")) {
            PropertiesConfiguration config = new PropertiesConfiguration(f);
            List<String> enabledCommands = config.getList("EnabledCommands").stream()
                    .map(object -> Objects.toString(object, null))
                    .collect(Collectors.toList());
            List<String> disabledCommands = config.getList("DisabledCommands").stream()
                    .map(object -> Objects.toString(object, null))
                    .collect(Collectors.toList());
            for (Command c : collection) {
                if (!enabledCommands.contains(c.toString()) && !disabledCommands.contains(c.toString())) {
                    enabledCommands.add(c.toString());
                }
            }
            config.setProperty("EnabledCommands", enabledCommands);
            config.save();
        }
    }
}
项目:Backmemed    文件:ResourcePackRepository.java   
/**
 * Keep only the 10 most recent resources packs, delete the others
 */
private void deleteOldServerResourcesPacks()
{
    try
    {
        List<File> list = Lists.newArrayList(FileUtils.listFiles(this.dirServerResourcepacks, TrueFileFilter.TRUE, (IOFileFilter)null));
        Collections.sort(list, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
        int i = 0;

        for (File file1 : list)
        {
            if (i++ >= 10)
            {
                LOGGER.info("Deleting old server resource pack {}", new Object[] {file1.getName()});
                FileUtils.deleteQuietly(file1);
            }
        }
    }
    catch (IllegalArgumentException illegalargumentexception)
    {
        LOGGER.error("Error while deleting old server resource pack : {}", new Object[] {illegalargumentexception.getMessage()});
    }
}
项目:CustomWorldGen    文件:ResourcePackRepository.java   
/**
 * Keep only the 10 most recent resources packs, delete the others
 */
private void deleteOldServerResourcesPacks()
{
    try
    {
        List<File> list = Lists.newArrayList(FileUtils.listFiles(this.dirServerResourcepacks, TrueFileFilter.TRUE, (IOFileFilter)null));
        Collections.sort(list, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
        int i = 0;

        for (File file1 : list)
        {
            if (i++ >= 10)
            {
                LOGGER.info("Deleting old server resource pack {}", new Object[] {file1.getName()});
                FileUtils.deleteQuietly(file1);
            }
        }
    }
    catch (IllegalArgumentException illegalargumentexception)
    {
        LOGGER.error("Error while deleting old server resource pack : {}", new Object[] {illegalargumentexception.getMessage()});
    }
}
项目:CreativeBlock    文件:FolderBlockPack.java   
@Override
public List<BlockDefinition> getDefinitions()
{
    List<BlockDefinition> definitions = new ArrayList<>();
    final File definitionsDir = FileUtil.getDir(this.getSource(), "assets", creativeBlock.domain(), "definitions");
    final File texturesDir = FileUtil.getDir(this.getSource(), "assets", creativeBlock.domain(), "textures", "blocks");

    Iterator<File> defIterator = FileUtils.iterateFilesAndDirs(definitionsDir, definitionsFilter(), TrueFileFilter.INSTANCE);
    while (defIterator.hasNext())
    {
        File file = defIterator.next();
        Optional<DefinitionSerializable> optional = JsonUtil.deserialize(file, DefinitionSerializable.class);
        if (optional.isPresent())
        {
            DefinitionSerializable jsonDefinition = optional.get();
            jsonDefinition.tabId = getTabName(definitionsDir, file);
            BlockDefinition definition = BlockDefinition.from(optional.get());
            definitions.add(definition);
        }
    }
    return definitions;
}
项目:musicdroid    文件:AppPresenter.java   
private List<File> getLocalAlbums() {
    final String musicDirectory = AppConfiguration.getConfigurationProperty("music.dir");

    final File directory = new File(musicDirectory);
    if (!directory.exists()) {
        return Collections.emptyList();
    }

    return FileUtils.listFilesAndDirs(directory,
            DirectoryFileFilter.DIRECTORY,
            TrueFileFilter.INSTANCE)
            .stream()
            .filter(file -> !file.getAbsolutePath().equals(musicDirectory))
            .sorted(Comparator.comparing(File::getAbsolutePath))
            .collect(Collectors.toList());
}
项目:Maven-Vault-Checkout-Plugin    文件:CleanHelper.java   
public static void cleanupDotContent(String root, String[] contentProperties) throws MojoExecutionException {
    for (File file : FileUtils.listFiles(new File(root), new NameFileFilter(".content.xml"),
            TrueFileFilter.INSTANCE)) {
        try {
            LOG.info("Cleaning up {}", file.getPath());
            List<String> lines = new ArrayList<String>();
            for (String line : FileUtils.readLines(file, CharEncoding.UTF_8)) {
                String cleanLine = StringUtils.trimToEmpty(line);
                boolean lineContains = lineContainsProperty(cleanLine, contentProperties);
                if (lineContains) {
                    if (!cleanLine.endsWith(">")) {
                    } else {
                        String lastLine = lines.remove(lines.size() - 1);
                        lines.add(lastLine + ">");
                    }
                } else {
                    lines.add(line);
                }
            }
            FileUtils.writeLines(file, CharEncoding.UTF_8, lines);
        } catch (IOException e) {
            throw new MojoExecutionException(String.format("Error opening %s", file.getPath()), e);
        }
    }
}
项目:mdetect    文件:FileScanUtils.java   
public static List<String> findGitRepos(String dirPath) {
    File dir = new File(dirPath);
    IOFileFilter gitDirFilter = (IOFileFilter) FileFilterUtils.suffixFileFilter(".git");
    IOFileFilter notFile = FileFilterUtils.notFileFilter(TrueFileFilter.INSTANCE);
    IOFileFilter compositeFilter = FileFilterUtils.and(notFile, gitDirFilter);

    List<File> files = (List<File>) FileUtils.listFilesAndDirs(dir,compositeFilter,DirectoryFileFilter.INSTANCE);
    List<String> results = new ArrayList<String>();
    for(File f: files) {
        try {
            if(!f.getCanonicalPath().endsWith("/.git"))
                continue;

            String gitStripped = f.getCanonicalPath().replace("/.git", "");
            System.out.println(gitStripped);
            results.add(gitStripped);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return results;
}
项目:gradle-mobile-plugin    文件:ZipUtil.java   
public static void compressDirectory(File rootDir, boolean includeAsRoot, File output) throws IOException {
    if (!rootDir.isDirectory()) {
        throw new IOException("Provided file is not a directory");
    }
    try (OutputStream archiveStream = new FileOutputStream(output);
         ArchiveOutputStream archive = new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, archiveStream)) {
        String rootName = "";
        if (includeAsRoot) {
            insertDirectory(rootDir, rootDir.getName(), archive);
            rootName = rootDir.getName()+"/";
        }
        Collection<File> fileCollection = FileUtils.listFilesAndDirs(rootDir, TrueFileFilter.TRUE, TrueFileFilter.TRUE);
        for (File file : fileCollection) {
            String relativePath = getRelativePath(rootDir, file);
            String entryName = rootName+relativePath;
            if (!relativePath.isEmpty() && !"/".equals(relativePath)) {
                insertObject(file, entryName, archive);
            }
        }
        archive.finish();
    } catch (IOException | ArchiveException e) {
        throw new IOException(e);
    }
}
项目:gradle-mobile-plugin    文件:ZipUtilTest.java   
private static List<String> getDirectoryEntryNames(File sourceDir) throws IOException {
    List<String> content = new ArrayList<>();
    for (File file : FileUtils.listFilesAndDirs(sourceDir, TrueFileFilter.TRUE, TrueFileFilter.TRUE)) {
        String relativePath = getRelativePath(sourceDir, file).replace("\\", "/");
        if (Files.isSymbolicLink(file.toPath())) {
            content.add("[l]"+relativePath);
        } else if (file.isDirectory() && !relativePath.isEmpty()) {
            content.add("[d]"+relativePath+"/");
        } else if (file.isFile()) {
            content.add("[f]"+relativePath);
        } else if (!relativePath.isEmpty()) {
            content.add("[?]"+relativePath);
        }
    }
    Collections.sort(content);
    return content;
}
项目:japi    文件:ProjectImpl.java   
@Override
public List<IPackage> getPackages() {
    String masterProjectActionPath = JapiClient.getConfig().getPrefixPath() + JapiClient.getConfig().getProjectJavaPath() + JapiClient.getConfig().getPostfixPath() + "/" + JapiClient.getConfig().getActionReletivePath();
    File actionFold = new File(masterProjectActionPath);
    if (!actionFold.exists()) {
        throw new JapiException(masterProjectActionPath + " fold not exists.");
    }
    final IOFileFilter dirFilter = FileFilterUtils.asFileFilter(new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.isDirectory();
        }
    });
    Collection<File> folds = FileUtils.listFilesAndDirs(actionFold, dirFilter, TrueFileFilter.INSTANCE);
    List<IPackage> packages = new ArrayList<>(folds.size());
    for (File fold : folds) {
        if (!fold.getAbsolutePath().equals(actionFold.getAbsolutePath())) {
            PackageImpl packageImpl = new PackageImpl();
            packageImpl.setPackageFold(fold);
            packages.add(packageImpl);
        }
    }
    return packages;
}
项目:PEP---Notes    文件:DataBackupIntentService.java   
private void importNotes(File backupDir) {
for (File file : FileUtils.listFiles(backupDir, new RegexFileFilter("\\d{13}"), TrueFileFilter.INSTANCE)) {
    try {
        Note note = new Note();
        note.buildFromJson(FileUtils.readFileToString(file));
        if (note.getCategory() != null) {
            DbHelper.getInstance().updateCategory(note.getCategory());
        }
        for (Attachment attachment : note.getAttachmentsList()) {
            DbHelper.getInstance().updateAttachment(attachment);
        }
        DbHelper.getInstance().updateNote(note, false);
    } catch (IOException e) {
        Log.e(Constants.TAG, "Error parsing note json");
    }
}
  }
项目:PEP---Notes    文件:DataBackupIntentService.java   
/**
 * Import attachments from backup folder
 */
private boolean importAttachments(File backupDir) {
    File attachmentsDir = StorageHelper.getAttachmentDir(this);
    // Moving back
    File backupAttachmentsDir = new File(backupDir, attachmentsDir.getName());
    if (!backupAttachmentsDir.exists()) return true;
    boolean result = true;
    Collection list = FileUtils.listFiles(backupAttachmentsDir, FileFilterUtils.trueFileFilter(),
            TrueFileFilter.INSTANCE);
    Iterator i = list.iterator();
    int imported = 0;
    File file = null;
    while (i.hasNext()) {
        try {
            file = (File) i.next();
            FileUtils.copyFileToDirectory(file, attachmentsDir, true);
            mNotificationsHelper.setMessage(TextHelper.capitalize(getString(R.string.attachment)) + " " + imported++ + "/" + list.size())
                    .show();
        } catch (IOException e) {
            result = false;
            Log.e(Constants.TAG, "Error importing the attachment " + file.getName());
        }
    }
    return result;
}
项目:textokit-core    文件:RusCorporaCollectionReader.java   
@Override
public void initialize(UimaContext ctx) throws ResourceInitializationException {
    super.initialize(ctx);
    tagMapper = InitializableFactory.create(ctx, tagMapperClassName, RusCorporaTagMapper.class);
    if (!inputDir.isDirectory()) {
        throw new IllegalArgumentException(String.format(
                "%s is not existing directory", inputDir));
    }
    relativeURIFunc = CorpusUtils.relativeURIFunction(inputDir);
    relativePathFunc = CorpusUtils.relativePathFunction(inputDir);
    String inputFileExt = DEFAULT_INPUT_FILE_EXT;
    inputFiles = ImmutableList.copyOf(
            FileUtils.listFiles(inputDir,
                    suffixFileFilter(inputFileExt),
                    TrueFileFilter.INSTANCE));
    getLogger().info(String.format("Detected *%s files in %s: %s",
            inputFileExt, inputDir, inputFiles.size()));
    try {
        SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser();
        xmlReader = saxParser.getXMLReader();
    } catch (Exception e) {
        throw new ResourceInitializationException(e);
    }
}
项目:isetools    文件:Command.java   
/**
 * 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;
}
项目:cloudera-framework    文件:DfsServer.java   
/**
 * Get a dataset, subset and label keyed map of the local file listing of
 * <code>path</code> matching specific dataset, subset and label
 * <code>paths</code>
 *
 * @param path  the path relative to the module root, can be with or without '/'
 *              prefix
 * @param paths optional list of dataset, subset and label paths to include, if
 *              not specified all paths at that level will be included
 * @return the local files as mapped by dataset, subset and label
 */
public static Map<String, Map<String, Map<String, List<File>>>> mapFilesLocal(String path, String... paths) {
  Map<String, Map<String, Map<String, List<File>>>> files = new TreeMap<>();
  for (File file : listFilesLocal(path, false, paths)) {
    String pathDataset = file.getParentFile().getParentFile().getParentFile().getName();
    String pathSubset = file.getParentFile().getParentFile().getName();
    String pathLabel = file.getParentFile().getName();
    files.computeIfAbsent(pathDataset, k -> new TreeMap<>());
    files.get(pathDataset).computeIfAbsent(pathSubset, k -> new TreeMap<>());
    files.get(pathDataset).get(pathSubset).computeIfAbsent(pathLabel, k -> new ArrayList<>());
    if (file.isFile()) {
      files.get(pathDataset).get(pathSubset).get(pathLabel).add(file);
    } else {
      files.get(pathDataset).get(pathSubset).get(pathLabel)
        .addAll(FileUtils.listFiles(file, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE));
    }
  }
  return files;
}
项目:springmvc-raml-plugin    文件:ClassLoaderUtils.java   
public static List<String> loadPackages(MavenProject mavenProject) throws MojoExecutionException {

        List<String> packages = Lists.newArrayList();

        logger.info("Loading packages in " + mavenProject.getBuild().getSourceDirectory() + "...");
        File rootDir = new File(mavenProject.getBuild().getSourceDirectory() + "//");
        Collection<File> files = FileUtils
                .listFilesAndDirs(rootDir, DirectoryFileFilter.DIRECTORY, TrueFileFilter.TRUE);
        for (File file : files) {
            String pack = file.toString().replace(rootDir.toString(), "").replace(File.separator, ".");
            if (pack.startsWith(".")) {
                pack = pack.substring(1, pack.length());
            }
            if (!pack.isEmpty()) {
                packages.add(pack);
            }
        }

        return packages;
    }
项目:cleartk    文件:DescriptorTestUtil.java   
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);
  }

}
项目:libre    文件:MkDocs.java   
@Override
public List<String> names() {
    return Lists.transform(
        Lists.newArrayList(
            FileUtils.listFiles(
                this.dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE
            )
        ),
        new Function<File, String>() {
            @Override
            public String apply(final File input) {
                return input.getName();
            }
        }
    );
}
项目:neembuu-uploader    文件:NeembuuUploader.java   
private void selectFolderButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectFolderButtonActionPerformed
    //Open up the Open File dialog
    //If the user clicks cancel or close, do not continue.
    f.setMultiSelectionEnabled(false);
    f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    f.setAcceptAllFileFilterUsed(false);
    if (f.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) {
        return;
    }

    File folder = f.getSelectedFile();

    //getSelectedFiles() returns as File array.
    //We need ArrayList for efficiency. So convert array to ArrayList
    this.files = new ArrayList<File>(FileUtils.listFiles(folder, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE));

    //Same stuff as in FileDrop code in constructor
    if (files.size() == 1) {
        inputFileTextField.setText(files.get(0) + "");
    } else {
        inputFileTextField.setText(files.size() + " " + Translation.T().nfilesselected());
    }
    NULogger.getLogger().info("Files selected");
}
项目:seauto    文件:PathUtils.java   
/**
 * Search for a specific file nested inside of a specific path
 * 
 * @param path
 *          - path that contains the file
 * @param fileName
 *          - file name of the file
 * @return - the file that was found
 * 
 * @throws IllegalStateException
 *           - if more then one file with that specific name was found.
 */
public static File getFileInPath(final String path, final String fileName)
{
  File dir = new File(path);

  // find the correct file
  List<File> files = (List<File>) FileUtils.listFiles(dir, FileFilterUtils.nameFileFilter(fileName), TrueFileFilter.TRUE);

  LOG.debug("Files found: {}", Arrays.asList(files));

  if (files.size() != 1) {
    throw new IllegalStateException(String.format("Searching for a file '%s' did not result in the correct number of files! Found %d, expected %d", fileName, files.size(), 1));
  }

  return files.get(0);
}
项目:EASyProducer    文件:ModelCopy.java   
/**
 * Starts the copy process.
 * @throws ModelManagementException If IVML files could not be parsed
 * @throws IOException If files could not be copied.
 */
private void copy() throws ModelManagementException, IOException {
    // Initialize
    loadProject(getSourceFolder(), getMainProject());
    Collection<File> originalFiles = FileUtils.listFiles(getSourceFolder(), new EASyModelFilter(),
        TrueFileFilter.INSTANCE);

    // Copy all files
    for (File file : originalFiles) {
        String relativeFileName = getSourceFolder().toURI().relativize(file.toURI()).getPath();
        debugMessage("Processing: " + relativeFileName);
        File copyDestination = new File(getDestinationFolder(), relativeFileName);
        if (!copyDestination.exists()) {
            File destFolder = copyDestination.getParentFile();
            destFolder.mkdirs();
            if (!relativeFileName.toLowerCase().endsWith(CONFIG_FILE_EXTENSION)) {
                FileUtils.copyFile(file, copyDestination, false);
            } else {
                handleConfigFile(relativeFileName, destFolder);
            }
        }
    }
}
项目:config-generation-maven-plugin    文件:DirectoryReader.java   
/**
 * Return collection of all files in directory and sub-directories, ignoring any that
 * have been specifically excluded in plugin configuration.
 */
@SuppressWarnings("rawtypes")
private Collection<File> getAllFiles(final File directory, final List<File> filesToIgnore) {
    if (!directory.exists()) {
        log.warn("Directory does not exist: " + directory.getPath());
        return EMPTY_FILE_LIST;
    }
    final Collection allFiles = FileUtils.listFiles(directory, TrueFileFilter.TRUE, DirectoryFileFilter.DIRECTORY);
    final Collection<File> files = new ArrayList<File>(allFiles.size());
    for (final Object o : allFiles) {
        if (o != null && o instanceof File) {
            final File file = (File) o;
            if (isFileToIgnore(file, filesToIgnore)) {
                log.debug("Ignoring : " + file.toString());
            } else {
                log.debug("Adding file: " + file.toString());
                files.add(file);
            }
        } else {
            log.warn("Not a file: " + ToStringBuilder.reflectionToString(o));
        }
    }
    return files;
}
项目:maven-repository-tools    文件:MavenRepositoryDeployer.java   
public static Collection<File> getLeafDirectories( File repoPath ) 
{
    // Using commons-io, if performance or so is a problem it might be worth looking at the Java 8 streams API
    // e.g. http://blog.jooq.org/2014/01/24/java-8-friday-goodies-the-new-new-io-apis/
    // not yet though..
   Collection<File> subDirectories =
        FileUtils.listFilesAndDirs( repoPath, (IOFileFilter) DirectoryFileFilter.DIRECTORY,
                                    TrueFileFilter.INSTANCE );
    Collection<File> leafDirectories = new ArrayList<File>();
    for ( File subDirectory : subDirectories )
    {
        if ( isLeafVersionDirectory( subDirectory ) && subDirectory != repoPath )
        {
            leafDirectories.add( subDirectory );
        }
    }
    return leafDirectories;
}
项目:Secrecy_fDroid_DEPRECIATED    文件:UpdateManager.java   
@Background
void version32to40() {
    //walks the whole file tree, find out files that do not have encoded file names
    //and encode them.
    Collection files = FileUtils.listFiles(storage.getRoot(), TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
    for (Object file : files) {
        File realFile = (File) file;
        String fileName = FilenameUtils.removeExtension(realFile.getName());
        fileName = fileName.replace("_thumb", "");
        if (".nomedia".equals(fileName))
            continue;
        try {
            Base64Coder.decodeString(fileName);
        } catch (IllegalArgumentException e) {
            String encodedFileName = Base64Coder.encodeString(fileName);
            fileName = realFile.getAbsolutePath().replace(fileName, encodedFileName);
            Boolean ignored = realFile.renameTo(new File(fileName));
        }
    }
    onFinishAllUpgrade();
}
项目:ExpandedRailsMod    文件:ResourcePackRepository.java   
/**
 * Keep only the 10 most recent resources packs, delete the others
 */
private void deleteOldServerResourcesPacks()
{
    try
    {
        List<File> list = Lists.newArrayList(FileUtils.listFiles(this.dirServerResourcepacks, TrueFileFilter.TRUE, (IOFileFilter)null));
        Collections.sort(list, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
        int i = 0;

        for (File file1 : list)
        {
            if (i++ >= 10)
            {
                LOGGER.info("Deleting old server resource pack {}", new Object[] {file1.getName()});
                FileUtils.deleteQuietly(file1);
            }
        }
    }
    catch (IllegalArgumentException illegalargumentexception)
    {
        LOGGER.error("Error while deleting old server resource pack : {}", new Object[] {illegalargumentexception.getMessage()});
    }
}
项目:tokentool    文件:ManageOverlays_Controller.java   
private boolean confirmDelete(File dir) {
    String confirmationText = I18N.getString("ManageOverlays.dialog.delete.dir.confirmation");
    long dirSize = FileUtils.listFiles(dir, ImageUtil.SUPPORTED_FILE_FILTER, TrueFileFilter.INSTANCE).size();

    if (dirSize == 0) {
        confirmationText += dir.getName() + I18N.getString("ManageOverlays.dialog.delete.dir.confirmation.directory");
    } else {
        confirmationText += dir.getName() + I18N.getString("ManageOverlays.dialog.delete.dir.directory_containing") + dirSize + I18N.getString("ManageOverlays.dialog.delete.dir.overlays");
    }

    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle(I18N.getString("ManageOverlays.dialog.delete.dir.title"));
    alert.setContentText(confirmationText);

    Optional<ButtonType> result = alert.showAndWait();

    if ((result.isPresent()) && (result.get() == ButtonType.OK)) {
        return true;
    }

    return false;
}
项目:mechaverse    文件:MechaverseStorageServiceImplTest.java   
@Test
public void removeSimulation() throws Exception {
  File basePath = folder.newFolder();
  service.setBasePath(basePath.getAbsolutePath());
  service.setState("1", "1", 0, new ByteArrayInputStream("This is a test.".getBytes()));

  assertEquals(5, FileUtils
    .listFilesAndDirs(basePath, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE).size());

  service.deleteSimulation("1");
  try {
    service.getState("1", "1", 0);
    fail("Expected exception was not thrown.");
  } catch(FileNotFoundException ex) {
    // Expected.
  }

  assertEquals(2, FileUtils
    .listFilesAndDirs(basePath, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE).size());
}
项目:mechaverse    文件:MechaverseStorageServiceImplTest.java   
@Test
public void removeInstance() throws Exception {
  File basePath = folder.newFolder();
  service.setBasePath(basePath.getAbsolutePath());
  service.setState("1", "1", 0, new ByteArrayInputStream("This is a test.".getBytes()));

  assertEquals(5, FileUtils
    .listFilesAndDirs(basePath, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE).size());

  service.deleteInstance("1", "1");
  try {
    service.getState("1", "1", 0);
    fail("Expected exception was not thrown.");
  } catch(FileNotFoundException ex) {
    // Expected.
  }

  assertEquals(3, FileUtils
    .listFilesAndDirs(basePath, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE).size());
}
项目:thindeck    文件:FkDecks.java   
@Override
public Iterable<Deck> iterate() {
    return Iterables.transform(
        FileUtils.listFiles(
            new File(this.path),
            TrueFileFilter.INSTANCE,
            TrueFileFilter.INSTANCE
        ),
        new Function<File, Deck>() {
            @Override
            public Deck apply(final File input) {
                return new FkDeck(input);
            }
        }
    );
}
项目:saos    文件:ContentSourceFileFinder.java   
/**
 * Finds content file in directory (or subdirectory) that 'corresponds' to
 * passed metadata file.
 * 
 * In our case 'corresponding' files means that files have the same name base
 * but extensions may differ.
 * Extension of returned file must be one of the {@link #setEligibleFileExtensions(String[])}
 */
public File findContentFile(File contentDir, File correspondingMetadataFile) {
    String filenameBase = extractFilenameBase(correspondingMetadataFile.getName());

    List<String> possibleFileNames = buildPossibleFilenames(filenameBase);

    Collection<File> foundContentFiles = FileUtils.listFiles(contentDir, new NameFileFilter(possibleFileNames), TrueFileFilter.INSTANCE);

    if (foundContentFiles.size() == 0) {
        throw new ImportException("No content file was found for " + correspondingMetadataFile + " in " + contentDir.getPath());
    }
    if (foundContentFiles.size() > 1) {
        throw new ImportException("More than one file found as content file candidate of " + correspondingMetadataFile);
    }

    return foundContentFiles.iterator().next();
}
项目:javaccPlugin    文件:CompiledJavaccFile.java   
private File scanSourceFiles(String compiledJavaccFilePackage, Collection<File> sourceFiles) {
    for (File sourceFile : sourceFiles) {
        logger.debug("Scanning source file [{}] looking for a file named [{}] in package [{}]", sourceFile, compiledJavaccFile.getName(), compiledJavaccFilePackage);
        if (sourceFile.isDirectory()) {
            Collection<File> childFiles = FileUtils.listFiles(sourceFile, FileFilterUtils.suffixFileFilter(".java"), TrueFileFilter.TRUE);
            File matchingChildFile = scanSourceFiles(compiledJavaccFilePackage, childFiles);
            if (matchingChildFile != null) {
                return matchingChildFile;
            }
        } else {
            if (FilenameUtils.isExtension(sourceFile.getName(), "java") && compiledJavaccFile.getName().equals(sourceFile.getName())) {
                String packageName = getPackageName(sourceFile);

                if (compiledJavaccFilePackage.equals(packageName)) {
                    return sourceFile;
                }
            }
        }
    }

    return null;
}
项目:writelatex-git-bridge    文件:Files.java   
private static Set<Path> getChildren(File f0, Path f0Base) {
    return FileUtils.listFilesAndDirs(
            f0,
            TrueFileFilter.TRUE,
            TrueFileFilter.TRUE
    ).stream(
    ).map(
            File::getAbsolutePath
    ).map(
            Paths::get
    ).map(p ->
            f0Base.relativize(p)
    ).filter(p ->
            !p.toString().isEmpty()
    ).collect(
            Collectors.toSet()
    );
}