java.lang.Object | |||
↳ | java.net.URLConnection | ||
↳ | sun.net.www.URLConnection | ||
↳ | sun.net.www.protocol.mailto.MailToURLConnection |
Handle mailto URLs. To send mail using a mailto URLConnection,
call getOutputStream
, write the message to the output
stream, and close it.
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Opens a communications link to the resource referenced by this
URL, if such a connection has not already been established.
| |||||||||||
Returns setting for connect timeout.
| |||||||||||
Returns an output stream that writes to this connection.
| |||||||||||
Returns a permission object representing the permission
necessary to make the connection represented by this
object.
| |||||||||||
Returns setting for read timeout.
| |||||||||||
Sets a specified timeout value, in milliseconds, to be used
when opening a communications link to the resource referenced
by this URLConnection.
| |||||||||||
Sets the read timeout to a specified timeout, in
milliseconds.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.
If the connect
method is called when the connection
has already been opened (indicated by the connected
field having the value true
), the call is ignored.
URLConnection objects go through two phases: first they are created, then they are connected. After being created, and before being connected, various options can be specified (e.g., doInput and UseCaches). After connecting, it is an error to try to set them. Operations that depend on being connected, like getContentLength, will implicitly perform the connection, if necessary.
IOException |
---|
Returns setting for connect timeout.
0 return implies that the option is disabled (i.e., timeout of infinity).
int
that indicates the connect timeout
value in millisecondsReturns an output stream that writes to this connection.
IOException |
---|
Returns a permission object representing the permission
necessary to make the connection represented by this
object. This method returns null if no permission is
required to make the connection. By default, this method
returns java.security.AllPermission
. Subclasses
should override this method and return the permission
that best represents the permission required to make a
a connection to the URL. For example, a URLConnection
representing a file:
URL would return a
java.io.FilePermission
object.
The permission returned may dependent upon the state of the connection. For example, the permission before connecting may be different from that after connecting. For example, an HTTP sever, say foo.com, may redirect the connection to a different host, say bar.com. Before connecting the permission returned by the connection will represent the permission needed to connect to foo.com, while the permission returned after connecting will be to bar.com.
Permissions are generally used for two purposes: to protect caches of objects obtained through URLConnections, and to check the right of a recipient to learn about a particular URL. In the first case, the permission should be obtained after the object has been obtained. For example, in an HTTP connection, this will represent the permission to connect to the host from which the data was ultimately fetched. In the second case, the permission should be obtained and tested before connecting.
IOException |
---|
Returns setting for read timeout. 0 return implies that the option is disabled (i.e., timeout of infinity).
int
that indicates the read timeout
value in millisecondsSets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection. If the timeout expires before the connection can be established, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.
Some non-standard implmentation of this method may ignore the specified timeout. To see the connect timeout set, please call getConnectTimeout().
timeout | an int that specifies the connect
timeout value in milliseconds |
---|
Sets the read timeout to a specified timeout, in milliseconds. A non-zero value specifies the timeout when reading from Input stream when a connection is established to a resource. If the timeout expires before there is data available for read, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.
Some non-standard implementation of this method ignores the specified timeout. To see the read timeout set, please call getReadTimeout().
timeout | an int that specifies the timeout
value to be used in milliseconds |
---|