我正在使用 Apache Commons VFS(虚拟文件系统)通过 SFTP 访问一些文件。有人知道如何检查 org.apache.commons.vfs.FileContent 的实例是否是文件夹吗?
最佳答案
如果您的意思是检查 FileObject
,那么你就可以使用 [ FileObject.getType()
]( http://commons.apache.org/vfs/apidocs/org/apache/commons/vfs/FileObject.html#getType() 。给定一个非空的 FileContent
,你总是会假设它来自一个文件。正如规范 here 所说:
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.
关于java - 如何检查 FileObject 是否是文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1120098/