commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Ivankovits <ma...@ops.co.at>
Subject Re: [VFS] getChildren()
Date Fri, 18 Feb 2005 07:18:59 GMT
Edgar Poce wrote:

> Hi
>  I want to list only the folder children and I don't find this method 
> in FileObject class.
>
> FileObject[] getChildren(FileTypeSelector selector) throws 
> FileSystemException

        final FileObject fo = 
VFS.getManager().resolveFile("/your/parent/directory");
        FileObject[] children = fo.findFiles(new 
FileTypeSelector(FileType.FOLDER)
        {
            public boolean includeFile(FileSelectInfo fileSelectInfo) 
throws FileSystemException
            {
                if (fileSelectInfo.getFile() == fo)
                {
                    return false;
                }
                return super.includeFile(fileSelectInfo);
            }

            public boolean traverseDescendents(FileSelectInfo 
fileSelectInfo)
            {
                return fileSelectInfo.getFile() == fo;
            }
        });

Should do the trick.

For sure - it would be best if you pack the above into your own 
FileSelector.

---
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message