Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HttpURLConnection

Status
Not open for further replies.

luciddream

Programmer
Nov 8, 2000
712
US
can someone show me how to use this class?

i try to make a new HttpURLConnection, which, atleast in my mind seems like a logical thing to do. on the other havd, javac doesn't seem to think it's as good of an idea as i do. it's telling me that it's an abstract class and can't be instantiated. alright, so, i'm supposed to use it's methods without creating a new object, fine. how do i do so? and why in the java.net documentation does it tell me that about the constructor and its parameter the url? any help will be appreciated.
 
From the JDK documentation for class URL:

Hope this helps
-pete

openConnection

public URLConnection openConnection()
throws IOException


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

A new connection is opened every time by calling the openConnection method of the protocol handler for this URL.

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 to the URL.

Throws:

IOException - if an I/O exception occurs.

See Also:

URL(java.lang.String, java.lang.String, int, java.lang.String), URLConnection, URLStreamHandler.openConnection(java.net.URL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top