将FileObject转换为文件 [英] Convert a FileObject into a File
本文介绍了将FileObject转换为文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Apache Commons VFS2(虚拟文件系统)来监控目录中的更改文件。 org.apache.commons.vfs2.FileListener
return org.apache.commons.vfs2.FileObject
。如何将 org.apache.commons.vfs2.FileObject
转换为 java.io.File
I'm using Apache Commons VFS2 (Virtual File System) to monitor change file in directory. org.apache.commons.vfs2.FileListener
return org.apache.commons.vfs2.FileObject
. How Convert a org.apache.commons.vfs2.FileObject
into a java.io.File
推荐答案
您可以使用
new File(fileobject.getName().getPath());
请注意,VFS文件对象不一定引用真实文件,它也可以引用文件内的文件例如一个zip文件。取决于您用于获取文件对象的解析器。
Note that a VFS file object does not necessarily references a real File, it can also reference a file within a zip file for example. Depends on the resolver you used to obtain a file object.
其他参考:
- [VFS-443] Need an easy way to convert from a FileObject to a File - ASF JIRA.
这篇关于将FileObject转换为文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文