if (file.isDirectory()) { URL url = getURL(); try { URLConnection connection = url.openConnection(); return connection.getContentLength(); } catch (IOException e) { return -1; } }
    public int getLength()    {      return (int) file.length();    }