Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

It's possible to get all files like this:

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

But, what I actually 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 resolve a set of files based on a regex with VFS?

like image 916
Mark Pope Avatar asked Sep 10 '11 08:09

Mark Pope


1 Answers

You could use the findFiles method, with a FileFilterSelector.

You'll need to create your own FileFilter that accepts the files that match your desired regex.

like image 58
Mat Avatar answered Sep 28 '22 00:09

Mat