long expectedBytes = src.length(); // This is the number of bytes we expected to copy..
If you want to provide information about the total number of bytes to be copied/has begin copied, it becomes a little more complicated.
You have choices here. You either pre-scan all the folders (I'd be placing the files into some kind of queue) and calculate the total bytes/number of files to be copied. Then start the actual copy process.
Updating the progress for this is as simple as the example before, except you'd be accumulating the total number of bytes you've copied over the whole process instead of a single file.
You could use a producer/consumer algorithm. The idea would be to start a thread/worker whose sole responsibility was to scan the folders for the files to be copied and place them into a central/shared queue (this is the producer).
You would have a second thread/worker that would pop the next item of this queue (blocking into a new file became available) and would actually copy the file.
Not the answer you're looking for? Browse other questions tagged java swing file-io swingworker jprogressbar or ask your own question.
How to create TIFF file?