2011-09-10 22 views
4

如果我有一個名爲temp與以下文件目錄:的Apache VFS resolveFile用正則表達式

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

這是可能得到的所有文件是這樣的:

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

但是,我真的想do得到a_file1.jpga_file2.jpg。也許喜歡:

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

但是,這將引發異常:

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

因此,沒有人知道如何解決基於與VFS正則表達式的一組文件?

回答

5

您可以使用findFiles方法,使用FileFilterSelector

你需要創建自己的FileFilteraccept是符合你想要的正則表達式的文件。

+0

Thanks Mat。 Google通過代碼示例發現此頁面: http://wiki.apache.org/commons/VfsFaq –