在文件夹中的文件:
myfile_mark_1.mp4
myfile_john_2.mp4
myfile_jake_3.mp4
myfile_tristan_4.mp4
yourfile_mark_1.mp4
如果我要查找前缀包含myfile_,后缀不大于3.mp4的(比如"_3.mp4", "_2.mp4", "_1.mp4")。
因此查找结果应该是:
myfile_mark_1.mp4
myfile_john_2.mp4 and
myfile_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"; }
暮色呼如
慕桂英4014372
相关分类