public URLConnection openConnection () throws IOException

Returns a URLConnection instance that represents a connection to the remote object referred to by the URL.

A new instance of URLConnection is created every time when invoking the java.net.URLStreamHandler.openConnection(URL) method of the protocol handler for this URL.

It should be noted that a URLConnection instance does not establish the actual network connection on creation. This will happen only when calling URLConnection.connect().

If for the URL's protocol (such as HTTP or JAR), there exists a public, specialized URLConnection subclass belonging to one of the following packages or one of their subpackages: java.lang, java.io, java.util, java.net, the connection returned will be of that subclass. For example, for HTTP an HttpURLConnection will be returned, and for JAR a JarURLConnection will be returned.

Returns:  a URLConnection linking to the URL.

Exceptions:
IOException    if an I/O exception occurs.

See also:
java.net.URL.URL(java.lang.String, java.lang.String, int, java.lang.String)