Java.Net.URLConnection Class
A connection to a URL for reading or writing.

See Also: URLConnection Members

Syntax

[Android.Runtime.Register("java/net/URLConnection", DoNotGenerateAcw=true)]
public abstract class URLConnection : Java.Lang.Object

Remarks

A connection to a URL for reading or writing. For HTTP connections, see Java.Net.HttpURLConnection for documentation of HTTP-specific features.

For example, to retrieve ftp://mirror.csclub.uwaterloo.ca/index.html:

java Example

URL url = new URL("ftp://mirror.csclub.uwaterloo.ca/index.html");
   URLConnection urlConnection = url.openConnection();
   InputStream in = new BufferedInputStream(urlConnection.getInputStream());
   try {
     readStream(in);
    finally {
     in.close();
   }
 }

URLConnection must be configured before it has connected to the remote resource. Instances of URLConnection are not reusable: you must use a different instance for each connection to a resource.

Timeouts

URLConnection supports two timeouts: a URLConnection.ConnectTimeout and a URLConnection.ReadTimeout. By default, operations never time out.

Built-in Protocols

Registering Additional Protocols

Use URL.SetURLStreamHandlerFactory(IURLStreamHandlerFactory) to register handlers for other protocol types.

[Android Documentation]

Requirements

Namespace: Java.Net
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1