Java PathMatcher create

Description

Java PathMatcher create

import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;

public class Main {
  public static void main(String[] args) {
    String globPattern = "glob:**java";
    PathMatcher matcher = FileSystems.getDefault().getPathMatcher(globPattern);
    Path path = Paths.get("Main.java");
    boolean matched = matcher.matches(path);
    System.out.format("%s matches %s: %b%n", globPattern, path, matched);
  }/*from  w w  w . j ava2 s. c  om*/
}



PreviousNext

Related