commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <>
Subject RE: [IO] Progress Monitor
Date Tue, 06 Apr 2010 22:09:04 GMT
> -----Original Message-----
> From: Rafał Krupiński []
> Sent: Tuesday, April 06, 2010 14:21
> To: Commons Developers List
> Subject: Re: [IO] Progress Monitor
> On 06.04.2010 19:03, Gary Gregory wrote:
> >> -----Original Message-----
> >> From: Rafał Krupiński []
> >> Sent: Tuesday, April 06, 2010 03:59
> >> To: Commons Developers List
> >> Subject: Re: [IO] Progress Monitor
> [...]
> >> interface ProgressMonitor{
> >>   void begin(int whole);
> >>   void progress(int current);
> >>   void end();
> >> }
> >>
> >> would suffice.
> >> What methods would you add this progress monitor support to?
> >> IOUtils.copy/Large - for sure, anywhere else?
> >
> > Everywhere a stream is used for input or output. Everywhere a File is used.
> I would like to replace my custom code with IOUtils and FilUtils calls to read
> from URL input streams and File objects pointing to network drives. Reading
> from local files that are large enough on a slow laptop drive needs feedback.
> >
> > I see adding a version of a method foo(...) with foo(..., ProgressMonitor)
> where foo(...) calls the other method with a NullMonitor.
> >
> > The API also needs to be able to see a message as part of the progress, so
> your version of begin() is too restrictive. You need to be able to say
> "Copying file Foo" and "Reading x of n KB", etc. The Eclipse folks have this
> pretty well figured out by now :)
> You want me to copy some bytes from one place to another and the source and
> the destination is provided by you.
> This is one operation, do I really have to tell you what am I doing? I'd say
> you know better.
> You can have your ConsoleProgressMonitor with task name and pretty messages,
> but copy() method really doesn't
> have to know that.

When I am copying a directory containing possibly hundreds of files, I do want to know how
far along I am. Recall that File objects describe both files and directories. When I am copying
one file, large or not, I do want to know how far along since the copying can be slow, especially
across a network.

The progress monitor itself can decide if the operation is fast enough to not bother with
providing actual progress feedback. For example, Eclipse does not bring up the progress dialog
if an operation is fast enough. This is a subtlety left to progress monitor implementations

> BTW, since you've mentioned copying streams, I would add 'void begin();' to be
> used when the size of the input
> is unknown.

When you are copying from a URL for example, you indeed do not know how big the source is
but you do know how much you have consumed, so it still makes sense to convey x of y type
of progress. You can even set up a size guess depending on the typical file size for you application.
In Eclipse, when the size is unknown, you just start progress with a total work unit of 1.


> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

View raw message