Java Path File Check nio isExcluded(Set excludes, Path path)

Here you can find the source of isExcluded(Set excludes, Path path)

Description

Checks if specified path is within excludes

License

Open Source License

Parameter

Parameter Description
excludes set of exclude matchers
path path being examined

Return

true if path is within excludes, false otherwise

Declaration

public static boolean isExcluded(Set<PathMatcher> excludes, Path path) 

Method Source Code


//package com.java2s;
/*/*from   www .j ava  2  s.  c  o  m*/
 * Copyright (c) 2012-2018 Red Hat, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */

import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.util.Set;

public class Main {
    /**
     * Checks if specified path is within excludes
     *
     * @param excludes set of exclude matchers
     * @param path path being examined
     * @return true if path is within excludes, false otherwise
     */
    public static boolean isExcluded(Set<PathMatcher> excludes, Path path) {
        for (PathMatcher matcher : excludes) {
            if (matcher.matches(path)) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. isEmpty(Path dir)
  2. isEmptyDir(Path dir)
  3. isEmptyDir(Path path)
  4. isEmptyDir(Path path)
  5. isEqualPath(final Path file1, final String topLevelAbsolutePath)
  6. isFile(final String path)
  7. isFile(Path file)
  8. isFileHidden(Path file)
  9. isFileSymLink(File path)