Java HttpURLConnection class

The Java HttpURLConnection class is http specific URLConnection. It works for HTTP protocol only.

By the help of HttpURLConnection class, you can information of any HTTP URL such as header information, status code, response code etc.

The java.net.HttpURLConnection is subclass of URLConnection class.

How to get the object of HttpURLConnection class

The openConnection() method of URL class returns the object of URLConnection class. Syntax:

public URLConnection openConnection()throws IOException{}

You can typecast it to HttpURLConnection type as given below.

Flash Soon


Java HttpURLConnecton Example

Flash Soon


Output:

Advertisement

Copyright ©2017 Design& develop