Date Archives July 21, 2016

HttpURLConnection vs. HttpsURLConnection

  • A URLConnection with support for HTTP-specific features
  • It can cover Https addresses also, because HttpsURLConnection extends this.
URL url = new URL("");

// HttpURLConnection can cover https URL.openconnection()
// because, HttpsURLConnection extends HttpURLConnection.
HttpURLConnection urlconnection = (HttpURLConnection) URL.openConnection();
   Inputstream in  = new BufferdInputStream(urlconnection.getInputStream());

  • HttpsURLConnection extends HttpURLConnection with support for https-specific features such as SSL
  • If HttpsURLConnection use same methods in HttpURLConnection(parent class), it super calls the methods from HttpURLConnection.