APISonar


com.google.common.io.Files.fileTreeTraverser

> com > google > common > io > Files > fileTreeTraverser
com APIs google APIs common APIs io APIs Files APIs fileTreeTraverser APIs

Example 1
private static void removeRecursive(Path path) throws IOException {
    Iterable<File> files = Files.fileTreeTraverser().postOrderTraversal(path.toFile());
    for (File f : files) {
      java.nio.file.Files.delete(f.toPath());
    }
  }
Example 2
public void testAllChecksPresentOnAvailableChecksPage() throws IOException {
        final String availableChecks = Files.toString(AVAILABLE_CHECKS_FILE, UTF_8);
        for (File file : Files.fileTreeTraverser().preOrderTraversal(JAVA_SOURCES_DIRECTORY)) {
            final String fileName = file.getName();
            if (fileName.matches(CHECK_FILE_NAME) && !IGNORE_LIST.contains(fileName)) {
                final String checkName = fileName.replace(CHECK_SUFFIX, "");
                if (!isPresent(availableChecks, checkName)) {
                    Assert.fail(checkName + " is not correctly listed on Available Checks page"
                            + " - add it to " + AVAILABLE_CHECKS_PATH);
                }
            }
        }
    }
Example 3
public static List<File> listFileWithRegexFileName(final File rootDir, final String regexFileNamePattern) {
		return Files.fileTreeTraverser().preOrderTraversal(rootDir)
				.filter(new RegexFileNameFilter(regexFileNamePattern)).toList();
	}
Example 4
public static List<File> find(@NonNull File base, @NonNull final Pattern pattern) {
        checkArgument(base.isDirectory(), "'base' must be a directory.");
        return Files.fileTreeTraverser()
                .preOrderTraversal(base)
                .filter(Predicates.compose(Predicates.contains(pattern), GET_PATH))
                .toList();
    }