Java判断后缀是否匹配规则
Java大约 447 字PathMatcher
使用JDK7
提供的API
。之前一般使用endsWith
判断以指定格式结尾。
public static void main(String[] args) {
PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:*.{gitignore,java,class,md,html}");
Path filename = Paths.get(".gitignore");
if (matcher.matches(filename)) {
System.out.println(filename);
} else {
System.out.println("not match");
}
}
参考
https://docs.oracle.com/javase/tutorial/essential/io/find.html
阅读 293 · 发布于 2020-05-26
————        END        ————
扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看换一批
- Spring Boot NoClassDefFoundError: com/mongodb/connection/DefaultClusterFactory阅读 224
- Android禁止EditText弹出软件盘阅读 1097
- Linux常用命令之网络相关命令阅读 508
- 走进Rust:HashMap集合阅读 329
- Golang命令之go build阅读 487
- Redis监控monitor阅读 390
- 软考-系统架构设计师:处理流程设计阅读 459
- HTTP Content-Type为application/x-www-form-urlencoded时注意事项阅读 683
- ThinkPHP5设置数据库长连接阅读 1306
- Android添加音效阅读 517