java.net.URLConnection (JDK 1.0)
This abstract class defines a network connection to an object specified by a URL. URL.openConnection() returns a URLConnection instance. You would use a URLConnection object when you want more control over the downloading of data than is available through the simpler URL methods.
connect() actually performs the network connection. Other methods that depend on being connected will call this method. getContent() returns the data referred to by the URL, parsed into an appropriate type of Object. If the URL protocol supports read and write operations, then getInputStream() and getOutputStream() respectively return input and output streams to the object referred to by the URL.
getContentLength(), getContentType(), getContentEncoding(), getExpiration(), getDate(), and getLastModified() return the appropriate information about the object referred to by the URL, if that information can be determined (e.g., from HTTP header fields). getHeaderField() returns an HTTP header field specified by name or by number. getHeaderFieldInt() and getHeaderFieldDate() return the value of a named header field parsed as an integer or a date.
There are a number of options that you may specify to control how the URLConnection behaves. These options are set with the various set() methods, and may be queried with corresponding get() methods. The options must be set before the connect() method is called. setDoInput() and setDoOutput() allow you to specify whether you use the URLConnection for input and/or output. The default is input-only. setAllowUserInteraction() specifies whether user interaction (such as typing a password) is allowed during the data transfer. The initial default is false. setDefaultAllowUserInteraction() is a class method that allows you to change the default value for user interaction. setUseCaches() allows you to specify whether a cached version of the URL may be used. You can set this to false to force a URL to be reloaded. setDefaultUseCaches() sets the default value for setUseCaches(). setIfModifiedSince() allows you to specify that a URL should not be fetched (if it is possible to determine its modification date) unless it has been modified since a specified time.
public abstract classURLConnectionextends Object { //Protected ConstructorprotectedURLConnection(URLurl); //Class Variables1.1public static FileNameMapfileNameMap; //Protected Instance Variablesprotected booleanallowUserInteraction; protected booleanconnected; protected booleandoInput; protected booleandoOutput; protected longifModifiedSince; protected URLurl; protected booleanuseCaches; //Class Methodspublic static booleangetDefaultAllowUserInteraction(); public static StringgetDefaultRequestProperty(Stringkey); protected static StringguessContentTypeFromName(Stringfname); public static StringguessContentTypeFromStream(InputStreamis) throws IOException; public static synchronized voidsetContentHandlerFactory(ContentHandlerFactoryfac); public static voidsetDefaultAllowUserInteraction(booleandefaultallowuserinteraction); public static voidsetDefaultRequestProperty(Stringkey, Stringvalue); //Public Instance Methodspublic abstract voidconnect() throws IOException; public booleangetAllowUserInteraction(); public ObjectgetContent() throws IOException; public StringgetContentEncoding(); public intgetContentLength(); public StringgetContentType(); public longgetDate(); public booleangetDefaultUseCaches(); public booleangetDoInput(); public booleangetDoOutput(); public longgetExpiration(); public StringgetHeaderField(Stringname); public StringgetHeaderField(intn); public longgetHeaderFieldDate(Stringname, longDefault); public intgetHeaderFieldInt(Stringname, intDefault); public StringgetHeaderFieldKey(intn); public longgetIfModifiedSince(); public InputStreamgetInputStream() throws IOException; public longgetLastModified(); public OutputStreamgetOutputStream() throws IOException; public StringgetRequestProperty(Stringkey); public URLgetURL(); public booleangetUseCaches(); public voidsetAllowUserInteraction(booleanallowuserinteraction); public voidsetDefaultUseCaches(booleandefaultusecaches); public voidsetDoInput(booleandoinput); public voidsetDoOutput(booleandooutput); public voidsetIfModifiedSince(longifmodifiedsince); public voidsetRequestProperty(Stringkey, Stringvalue); public voidsetUseCaches(booleanusecaches); public StringtoString(); //Overrides Object}
Extended By:
HttpURLConnection
Passed To:
ContentHandler.getContent()
Returned By:
URL.openConnection(), URLStreamHandler.openConnection()