• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Java FTP Progress Bar

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Iam developing a multimedia web application using struts framework. Iam working on upload feature where i am supposed to upload the media file onto remote ftp streaming server.

Iam using apache ' commons-net-1.4.1.jar ' API for ftp operations.

When the user is uploading a media to the ftp, i need to show the upload progress bar.
Can any one suggest me a rich progress bar implementation API for this.

I have tried in the net, I found progress bar from dwr, but i was not a accurate one.

Please help me.

Thanks for your time in advance,
Venkat


[ October 03, 2008: Message edited by: Venkata Guru ]
 
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, if you need user interface elements, you should look in java.awt and javax.swing. The latter has JProgressBar, or perhaps even more useful ProgressMonitor and ProgressMonitorInputStream.

Also check out How to Monitor Progress from The Java Tutorial.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think that the library provides this kind of feedback (how much data has been transferred) to the client application.

A workaround might be to write a wrapper for the InputStream class that keeps track of how many bytes have been read (by overriding the various read methods), but otherwise passes all calls directly through to the underlying stream. You could then pass that wrapper to the storeFile method.
[ October 03, 2008: Message edited by: Ulf Dittmer ]
 
Rob Spoor
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But if you use ProgressMonitorInputStream, you can use FTPClient's storeFileStream method, and do the copying manually.


Actually, ProgressMonitorInputStream does exactly what you suggest. For example, the read(byte[]) method:


Edit: wait a sec. Why do the copying yourself? FTPClient's storeFile method takes an InputStream already. Just use the ProgressMonitorInputStream instead of the FileInputStream.
[ October 03, 2008: Message edited by: Rob Prime ]
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ProgressMonitorInputStream


Cool! I never knew about that class. Yes, it implements precisely what I had in mind.
 
Rob Spoor
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And if you always want to show it you can set the millis to decice and to popup of its ProgressMonitor to 0.
 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What if you don't have a gui component to your program? As far as I can tell, the ProgressMonitorInputStream pops up a dialog displaying the progress. I just want to know what the progress is so I can occasionally update my logs.

Is there an automatic way to do this, or do I have to create my own InputStream implementation?

Thanks.
 
Rob Spoor
Sheriff
Posts: 22821
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unless someone has done this in some 3rd party library, probably yes.

I take it you want to print a # everytime a specific percentage is reached? It's still quite easy, provided you know the total size to transfer.
 
Bai Shen
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rob Prime:
Unless someone has done this in some 3rd party library, probably yes.

I take it you want to print a # everytime a specific percentage is reached? It's still quite easy, provided you know the total size to transfer.



Something like that. I just want to make sure it's not hung when doing long transfers. Right now it just sits there until the file is finished.
 
Creativity is allowing yourself to make mistakes; art is knowing which ones to keep. Keep this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic