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
fileobject.getURL().getFile()
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.
You can use
new File(fileobject.getName().getPath());
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.
Additional references:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With