Java Path File List nio pathContainsAny(List strings)

Here you can find the source of pathContainsAny(List strings)

Description

path Contains Any

License

Apache License

Return

Predicate which returns true when path contains any of given string

Declaration

public static Predicate<Path> pathContainsAny(List<String> strings) 

Method Source Code


//package com.java2s;
/*//  w ww .j av  a 2s  . c om
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.nio.file.Path;
import java.util.List;
import java.util.function.Predicate;

public class Main {
    /**
     * @return Predicate which returns true when path contains any of given string
     */
    public static Predicate<Path> pathContainsAny(List<String> strings) {
        return path -> {
            boolean included = strings.stream()
                    .anyMatch(wildcardMatcher -> path.toString().contains(wildcardMatcher));
            return included;
        };
    }
}

Related

  1. listSteps(Path scenarioDirectory)
  2. loadDataFilesList(String prefix, Path bwcIndicesPath)
  3. loadTrainingData(Path path, List input, List output, int outputCount)
  4. mergeFiles(List files, Path mergedFile)
  5. mergeInto(List parts, OutputStream out)
  6. recursiveListFiles(Path file)
  7. recusivelyCollectFileListing(ArrayList rc, Path base, Path directory)
  8. registerRecursive(final WatchService watcher, final List startingPaths)
  9. retrieveTokenFilesInDirImportableFrom(Path dir, List excludedTokenFiles)