wrote:
> The problem is I can't figure out how to add a progress bar to a
> single-file upload. I can't seem to figure out how many bytes have
> actually been SENT over the internet connection.
>
>
> I am using DataOutputStream and httpUrlConnection
>
>
> Does anyone have any suggestions, ideas, or samples?
I haven't tried this, but:
use one of the set...StreamingMode() methods, so HttpURLConnection
doesn't buffer (you need to provide a chunk size or the total file
length, depending on the streaming mode you want to use). Then wrap the
file reading in a ProgressMonitorInputStream.
If you use the fixed' length mode, don't put any (large) buffers between
the InputStream and your code which copies the input stream to the
HttpURLConnection's output stream. Then the display should be reasonably
"accurate". Of course, you should put a BufferedReader around the
initial FileInputStream. Note, you do *not* want the order in the
example of the ProgressMonitorInputStream's API documentation.
Using chunked streaming mode might be the better alternative of the two
modes. If you do so, you could e.g. match chunk size and any internal
buffer size which might turn out to be useful.
/Thomas
--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq