使用正则表达式的Apache VFS resolveFile

Mar*_*ope 5 java apache-commons-vfs

如果我有一个temp使用以下文件调用的目录:

a_file1.jpg
a_file2.jpg
b_file1.jpg
b_file2.jpg
Run Code Online (Sandbox Code Playgroud)

有可能得到这样的所有文件:

VFS.getManager().resolveFile("temp").getChildren();
Run Code Online (Sandbox Code Playgroud)

但是,我真正想做的是得到a_file1.jpga_file2.jpg.也许喜欢:

VFS.getManager().resolveFile("temp/a*").getChildren();
Run Code Online (Sandbox Code Playgroud)

但这引发了一个例外:

org.apache.commons.vfs.FileSystemException: Could not list the contents of "temp/a*" because it is not a folder.
Run Code Online (Sandbox Code Playgroud)

那么,有没有人知道如何基于VFS的正则表达式解析一组文件?

Mat*_*Mat 5

您可以使用该findFiles方法FileFilterSelector.

你需要创建自己的FileFilteraccept的比赛你想要的正则表达式的文件.