if (file.isDirectory()) { URL url = getURL(); try { URLConnection connection = url.openConnection(); return connection.getContentLength(); } catch (IOException e) { return -1; } }
    public int getLength()    {      // Delegate to the URL content handler mechanism to retrieve the      // length of the HTML representation of the directory listing if      // a directory, or -1 if an exception occurs opening the directory.      if (file.isDirectory())        {          URL url = getURL();          try            {              URLConnection connection = url.openConnection();              return connection.getContentLength();            }          catch (IOException e)            {              return -1;            }        }      // Otherwise simply return the file length      return (int) file.length();    }