Does anyone know any way of implementing progress bar for Apache's FileUtils.copyDirectory(File src, File dst)
? I don't see anything helpful in JavaDocs and API. Seems like a common use case in dealing with batch disk operations, so I'm not sure if I miss something obvious.
相关问题
- 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
For anyone interested, I did this by coping the
doCopyFile
method from FileUtils and the couple of methods that lead up to it. I then pasted them into a new class so that I could edit the methods rather than only using the fixed FileUtils methods.Then I changed this part of the
doCopyFile
method:To this: (update the progress bar every time the buffer is emptied, not the best way)
For a better way the copy would be run in a different thread, and the progress bar would be updated in the EDT (using the
bytesTransfered
value and the total size of the files that are being copied):Then to update the progress bar on the EDT fire events with something like this:
I guess you will have to do that yourself. I see this immediate solution:
FileUtils.copyDirectory(File, File, FileFilter)
and "abuse" theFileFilter
as a callback to communicate progress to your progress bar