code: public static long getUriSize(String urlStr) {
          HttpURLConnection conn = null;
          try {
              URL url = new URL(urlStr);
              conn = (HttpURLConnection) url.openConnection();
              conn.setRequestMethod("HEAD");
              conn.getInputStream();
              return conn.getContentLengthLong();
          } catch (IOException e) {
              log.debug("Error", e);
              return -1;
          } finally {
              if (conn!=null) {
                  conn.disconnect();
              }
          }
      }
docs: Calculates the size of the remote resource
  taken from http://stackoverflow.com/a/7673089
  
  @param urlStr the uri to check
  @return the exact size or -1 in case of an error or unknown length