[jsword-devel] Getting the download size of modules

DM Smith dmsmith555 at yahoo.com
Wed Sep 22 16:08:23 MST 2004


I did a test to get the download size of the zip file for a module.

The code is pretty simple:
    public int getSize(URL file)
    {
        try
        {
            URLConnection urlConnection = file.openConnection();
            int size = urlConnection.getContentLength();
            return size;
        }
        catch (IOException e)
        {
            return 0;
        }
    }

This works with http:// urls to the zipped modules, but it is general 
and should work for ftp:// and file:// as well.

I decided to test how long it would take to get all the "supported" 
(i.e. not locked and not gen book) modules.
It took 55 seconds to iterate over all of them.
I have broadband, so I imagine it will be significantly slower w/ dialup.

So I don't think this is a good technique. But it is better than 
getting, reading and parsing a directory listing.

Obviously we won't be able to do this in the foreground. But do we want 
to do it at all?

Or do we just want to let the user know the size in a confirmation 
dialog when they choose to do an install?

Any other ideas?





More information about the jsword-devel mailing list