code: @Override
     public long getLength()
     {
        if (file != null)
        {
           return PrivilegedFileHelper.length(file);
        }
        else if (tempFile != null)
        {
           return PrivilegedFileHelper.length(tempFile);
        }
        else if (stream instanceof FileInputStream)
        {
           try
           {
              return ((FileInputStream)stream).getChannel().size();
           }
           catch (IOException e)
           {
              return -1;
           }
        }
        else if (url != null)
        {
           try
           {
              URLConnection connection = url.openConnection();
              return connection.getContentLength();
           }
           catch (IOException e)
           {
              return -1;
           }
        }
        else
        {
           try
           {
              return stream.available();
           }
           catch (IOException e)
           {
              return -1;
           }
        }
     }
docs: {@inheritDoc}