문제

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