API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.net. URLConnection View Source
Author(s)
James Gosling
Since
JDK1.0
Version
1.106, 06/28/06
Serial
Hierarchy
 Object
      URLConnection
Implements
Subclasses
Description
publicabstract abstract class URLConnection
  The abstract class URLConnection is the superclass of all classes that represent a communications link between the application and a URL.
Constructors
protected URLConnection (URL url)
  Constructs a URL connection to the specified URL.
Methods
Hide/Show inherited methods
public void addRequestProperty (String key, String value)
  Adds a general request property specified by a key-value pair.
publicabstract void connect () throws IOException
  Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.
public boolean getAllowUserInteraction ()
  Returns the value of the allowUserInteraction field for this object.
public int getConnectTimeout ()
  Returns setting for connect timeout.
public Object getContent () throws IOException
  Retrieves the contents of this URL connection.
public Object getContent (Class classes) throws IOException
  Retrieves the contents of this URL connection.
public String getContentEncoding ()
  Returns the value of the content-encoding header field.
pack-privatesynchronized ContentHandler getContentHandler () throws UnknownServiceException
  Gets the Content Handler appropriate for this connection.
public int getContentLength ()
  Returns the value of the content-length header field.
public String getContentType ()
  Returns the value of the content-type header field.
public long getDate ()
  Returns the value of the date header field.
publicstatic boolean getDefaultAllowUserInteraction ()
  Returns the default value of the allowUserInteraction field.
@Deprecated
publicstatic String getDefaultRequestProperty (String key)
  Returns the value of the default request property.
public boolean getDefaultUseCaches ()
  Returns the default value of a URLConnection's useCaches flag.
public boolean getDoInput ()
  Returns the value of this URLConnection's doInput flag.
public boolean getDoOutput ()
  Returns the value of this URLConnection's doOutput flag.
public long getExpiration ()
  Returns the value of the expires header field.
publicstaticsynchronized FileNameMap getFileNameMap ()
  Loads filename map (a mimetable) from a data file.
public String getHeaderField (int n)
  Returns the value for the nth header field.
public String getHeaderField (String name)
  Returns the value of the named header field.
public long getHeaderFieldDate (String name, long Default)
  Returns the value of the named field parsed as date.
public int getHeaderFieldInt (String name, int Default)
  Returns the value of the named field parsed as a number.
public String getHeaderFieldKey (int n)
  Returns the key for the nth header field.
public Map<String, List<String>> getHeaderFields ()
  Returns an unmodifiable Map of the header fields.
public long getIfModifiedSince ()
  Returns the value of this object's ifModifiedSince field.
public InputStream getInputStream () throws IOException
  Returns an input stream that reads from this open connection.
public long getLastModified ()
  Returns the value of the last-modified header field.
public OutputStream getOutputStream () throws IOException
  Returns an output stream that writes to this connection.
public Permission getPermission () throws IOException
  Returns a permission object representing the permission necessary to make the connection represented by this object.
public int getReadTimeout ()
  Returns setting for read timeout.
public Map<String, List<String>> getRequestProperties ()
  Returns an unmodifiable Map of general request properties for this connection.
public String getRequestProperty (String key)
  Returns the value of the named general request property for this connection.
public URL getURL ()
  Returns the value of this URLConnection's URL field.
public boolean getUseCaches ()
  Returns the value of this URLConnection's useCaches field.
publicstatic String guessContentTypeFromName (String fname)
  Tries to determine the content type of an object, based on the specified "file" component of a URL.
publicstatic String guessContentTypeFromStream (InputStream is) throws IOException
  Tries to determine the type of an input stream based on the characters at the beginning of the input stream.
public void setAllowUserInteraction (boolean allowuserinteraction)
  Set the value of the allowUserInteraction field of this URLConnection.
public void setConnectTimeout (int timeout)
  Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection.
publicstaticsynchronized void setContentHandlerFactory (ContentHandlerFactory fac)
  Sets the ContentHandlerFactory of an application.
publicstatic void setDefaultAllowUserInteraction (boolean defaultallowuserinteraction)
  Sets the default value of the allowUserInteraction field for all future URLConnection objects to the specified value.
@Deprecated
publicstatic void setDefaultRequestProperty (String key, String value)
  Sets the default value of a general request property.
public void setDefaultUseCaches (boolean defaultusecaches)
  Sets the default value of the useCaches field to the specified value.
public void setDoInput (boolean doinput)
  Sets the value of the doInput field for this URLConnection to the specified value.
public void setDoOutput (boolean dooutput)
  Sets the value of the doOutput field for this URLConnection to the specified value.
publicstatic void setFileNameMap (FileNameMap map)
  Sets the FileNameMap.
public void setIfModifiedSince (long ifmodifiedsince)
  Sets the value of the ifModifiedSince field of this URLConnection to the specified value.
public void setReadTimeout (int timeout)
  Sets the read timeout to a specified timeout, in milliseconds.
public void setRequestProperty (String key, String value)
  Sets the general request property.
public void setUseCaches (boolean usecaches)
  Sets the value of the useCaches field of this URLConnection to the specified value.
public String toString ()
  Returns a String representation of this URL connection.
Fields
Hide/Show inherited fields
protected boolean allowUserInteraction
  If true, this URL is being examined in a context in which it makes sense to allow user interactions such as popping up an authentication dialog.
protected boolean connected
  If false, this connection object has not created a communications link to the specified URL.
protected boolean doInput
  This variable is set by the setDoInput method.
protected boolean doOutput
  This variable is set by the setDoOutput method.
pack-privatestatic ContentHandlerFactory factory
The ContentHandler factory.
protected long ifModifiedSince
  Some protocols support skipping the fetching of the object unless the object has been modified more recently than a certain time.
protected URL url
  The URL represents the remote object on the World Wide Web to which this connection is opened.
protected boolean useCaches
  If true, the protocol is allowed to use caching whenever it can.
Nested Classes
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar