code: public static byte[] getContentFromUrl(URL url, Map inCookies, Map outCookies, boolean allowAllCerts)
      {
          URLConnection c = null;
          try
          {
              c = getConnection(url, inCookies, true, false, false, allowAllCerts);
  
              ByteArrayOutputStream out = new ByteArrayOutputStream(16384);
              InputStream stream = IOUtilities.getInputStream(c);
              IOUtilities.transfer(stream, out);
              stream.close();
  
              if (outCookies != null)
              {   // [optional] Fetch cookies from server and update outCookie Map (pick up JSESSIONID, other headers)
                  getCookies(c, outCookies);
              }
  
              return out.toByteArray();
          }
          catch (SSLHandshakeException e)
          {   // Don't read error response.  it will just cause another exception.
              LOG.warn("SSL Exception occurred fetching content from url: " + url, e);
              return null;
          }
          catch (Exception e)
          {
              readErrorResponse(c);
              LOG.warn("Exception occurred fetching content from url: " + url, e);
              return null;
          }
          finally
          {
              if (c instanceof HttpURLConnection)
              {
                  disconnect((HttpURLConnection)c);
              }
          }
      }
docs: Get content from the passed in URL.  This code will open a connection to
  the passed in server, fetch the requested content, and return it as a
  byte[].
  
  @param url URL to hit
  @param inCookies Map of session cookies (or null if not needed)
  @param outCookies Map of session cookies (or null if not needed)
  @param allowAllCerts override certificate validation?
  @return byte[] of content fetched from URL.