質問

With this lines I'm get a list with all files under but also the current directory

List<FileObject> fileList = new ArrayList<FileObject>();
FileObject fileObject = ...
fileObject.findFiles(new AllFileSelector(), depthwise, fileList);

the list content it:

/foo/boo/bla.jpg
/foo/tal.jpg
/foo/cheese.jpg
/foo

and I want to get just this:

/foo/boo/bla.jpg
/foo/tal.jpg
/foo/cheese.jpg

have I set something in the selector?

thanks

役に立ちましたか?

解決

Use the FileTypeSelector or implement your own FileSelector.

fileObject.findFiles(new FileTypeSelector(FileType.FILE), depthwise, fileList);

This example will only select files and not directories. This might be sufficient for your current problem, but if you want to filter files based on their extension, e.g. ".png", then you must implement your own org.apache.commons.vfs2.FileFilter and use a FileFilterSelector.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top