I am trying to figure out to how create a JProgressBar that monitors the progress of a downlaod through ftp. I am using the package from jakarta called commons.net.ftp.FTPClient to download the file. I am able to get the file size with no problems but I can't figure out how to get the current state that the FileOutputStream is in (fileSize of the current download). Any ideas on how to do this?
You can create a FilterInputStream or FilterOutputStream which counts the number of bytes that pass through it. In fact half the work for this is already done for you by CheckedInputStream and CheckedOutputStream - you can just make a single Checksum to count bytes, and then insert a CheckedInputStream or CheckedOutputStream into whatever stream you want to monitor: