import java.nio.file.FileSystems; import java.nio.file.Path; import java.nio.file.PathMatcher; public class GlobExample { public static void main(String[] args) { PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:*.txt"); Path path = Path.of("C:/path/to/file.txt"); if (matcher.matches(path)) { System.out.println("File matches the pattern"); } else { System.out.println("File does not match the pattern"); } } }


上一篇:
下一篇:
切换中文