Share via


URL.OpenConnection Method

Definition

Overloads

OpenConnection(Proxy)

Same as #openConnection(), except that the connection will be made through the specified proxy; Protocol handlers that do not support proxing will ignore the proxy parameter and make a normal connection.

OpenConnection()

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

OpenConnection(Proxy)

Same as #openConnection(), except that the connection will be made through the specified proxy; Protocol handlers that do not support proxing will ignore the proxy parameter and make a normal connection.

[Android.Runtime.Register("openConnection", "(Ljava/net/Proxy;)Ljava/net/URLConnection;", "")]
public Java.Net.URLConnection? OpenConnection (Java.Net.Proxy? proxy);
[<Android.Runtime.Register("openConnection", "(Ljava/net/Proxy;)Ljava/net/URLConnection;", "")>]
member this.OpenConnection : Java.Net.Proxy -> Java.Net.URLConnection

Parameters

proxy
Proxy

the Proxy through which this connection will be made. If direct connection is desired, Proxy.NO_PROXY should be specified.

Returns

a URLConnection to the URL.

Attributes

Exceptions

if an I/O error occurs while opening the connection.

if the argument proxy is null or of is an invalid type.

if the protocol handler does not support opening connections through proxies.

Remarks

Same as #openConnection(), except that the connection will be made through the specified proxy; Protocol handlers that do not support proxing will ignore the proxy parameter and make a normal connection.

Invoking this method preempts the system's default ProxySelector settings.

Added in 1.5.

Java documentation for java.net.URL.openConnection(java.net.Proxy).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

OpenConnection()

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

[Android.Runtime.Register("openConnection", "()Ljava/net/URLConnection;", "")]
public Java.Net.URLConnection? OpenConnection ();
[<Android.Runtime.Register("openConnection", "()Ljava/net/URLConnection;", "")>]
member this.OpenConnection : unit -> Java.Net.URLConnection

Returns

a java.net.URLConnection URLConnection linking to the URL.

Attributes

Exceptions

if an error occurs while opening the connection.

Remarks

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

A new instance of java.net.URLConnection URLConnection is created every time when invoking the java.net.URLStreamHandler#openConnection(URL) 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 java.net.URLConnection#connect() 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.

Java documentation for java.net.URL.openConnection().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to