Apache VFS resolveFile with regex

If I have a directory called temp with the following files:

 a_file1.jpg a_file2.jpg b_file1.jpg b_file2.jpg 

You can get all of these files:

 VFS.getManager().resolveFile("temp").getChildren(); 

But what I really want to do is get a_file1.jpg and a_file2.jpg . Maybe like:

 VFS.getManager().resolveFile("temp/a*").getChildren(); 

But this throws an exception:

 org.apache.commons.vfs.FileSystemException: Could not list the contents of "temp/a*" because it is not a folder. 

So does anyone know how to allow a regex file set with VFS?

+4
source share
1 answer

You can use the findFiles method with FileFilterSelector .

You need to create your own FileFilter , which accept files matching your desired regular expression.

+5
source

All Articles