Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if FileObject is folder?

I'm using Apache Commons VFS (Virtual File System) to access some files over SFTP. Does anybody know how to check if an instance of org.apache.commons.vfs.FileContent is folder?

like image 361
Boris Pavlović Avatar asked Jan 24 '23 10:01

Boris Pavlović


1 Answers

If you mean checking FileObject, then you can use [FileObject.getType()](http://commons.apache.org/vfs/apidocs/org/apache/commons/vfs/FileObject.html#getType(). Given a non-empty FileContent, you would always assume it's coming from a file. As the specification here says:

There are two types of files: Folders, which contain other files, and normal files, which contain data, or content. A folder may not have any content, and a normal file cannot contain other files.

like image 76
notnoop Avatar answered Jan 29 '23 23:01

notnoop