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
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You can use
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:
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.
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.LocalFileThis class offers the method
getLocalFile()
which return an object of the classjava.io.File
If you are not dealing with a
LocalFile
most of the other implementations offerdoGetInputStream()
which can be used to create a File object