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
Convert a FileObject into a File
12.6k views Asked by Gleb Belyaev At
3
There are 3 answers
2
On
org.apache.commons.vfs2.FileObject
is an interface.
My guess is, that you are working with the following implementation org.apache.commons.vfs2.provider.local.LocalFile
This class offers the method getLocalFile()
which return an object of the class java.io.File
If you are not dealing with a LocalFile
most of the other implementations offer doGetInputStream()
which can be used to create a File object
should work. The caveat is that we need to convert it first to a Java URL object, which can then be used to resolve the file.