在文件夹中的文件:myfile_mark_1.mp4myfile_john_2.mp4myfile_jake_3.mp4myfile_tristan_4.mp4yourfile_mark_1.mp4如果我要查找前缀包含myfile_,后缀不大于3.mp4的(比如"_3.mp4", "_2.mp4", "_1.mp4")。因此查找结果应该是:myfile_mark_1.mp4myfile_john_2.mp4 andmyfile_jake_3.mp4不知道怎么实现?我的代码:String myDirectory = Environment.getExternalStorageDirectory().getAbsolutePath();
File f = new File(myDirectory);
if(f.exists() && f.isDirectory()){
final Pattern p = Pattern.compile("myfile_*\\_(^0*(1?\\d|%d)$).mp4"); // I know I really have a stupid mistake on the regex;
File[] flists = f.listFiles(new FileFilter(){
@Override
public boolean accept(File file) {
return p.matcher(file.getName()).matches();
}
});
String s = "wait a minute, i'm debugging";
}
添加回答
举报
0/150
提交
取消