Difference between URLConnection, HttpURLConnection and HttpsURLConnection

Questions picture Questions · Oct 13, 2010 · Viewed 34.7k times · Source

What is the difference between URLConnection, HttpURLConnection and HttpsURLConnection (with SSL). Under what conditions, which one should I use?

Answer

user207421 picture user207421 · Oct 13, 2010

URLConnection is the base class.

HttpURLConnection is a derived class which you can use when you need the extra API and you are dealing with HTTP or HTTPS only.

HttpsURLConnection is a 'more derived' class which you can use when you need the 'more extra' API and you are dealing with HTTPS only.

All three of them are abstract, and implemented by specific classes you aren't privy to.