What would be the most common way to monitor the progress of compressing files? Is there a way to estimate the time it will take to compress a file or a directory? I'm trying to implement a progress bar for an application in java that zip files.
Thanks in advance for your answers!
You cannot estimate time. It depends on too many parameters and might vary from one second to the next. It is tempting to monitoring the output on the zip stream but you cannot guess in advance of much space the compressed file will take. So it won't work either.
The best way would be to browse all the files you're going to compress, sum their sizes and as you stream data into the zip, move the progress bar proportionally. I would also suggest to add a counter like
345/554 filesso that you also have an idea of the number of files.If you want more specific suggestions, you'll need to share some code of your attempt.