URL Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
URL(String) |
Creates a |
URL(URL, String) |
Creates a URL by parsing the given spec within a specified context. |
URL(URL, String, URLStreamHandler) |
Creates a URL by parsing the given spec with the specified handler within a specified context. |
URL(String, String, String) |
Creates a URL from the specified |
URL(String, String, Int32, String) |
Creates a |
URL(String, String, Int32, String, URLStreamHandler) |
Creates a |
URL(String)
Creates a URL
object from the String
representation.
[Android.Runtime.Register(".ctor", "(Ljava/lang/String;)V", "")]
public URL (string? spec);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;)V", "")>]
new Java.Net.URL : string -> Java.Net.URL
Parameters
- spec
- String
the String
to parse as a URL.
- Attributes
Exceptions
if spec
could not be parsed as a
URL.
Remarks
Creates a URL
object from the String
representation.
This constructor is equivalent to a call to the two-argument constructor with a null
first argument.
Java documentation for java.net.URL.URL(java.lang.String)
.
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
URL(URL, String)
Creates a URL by parsing the given spec within a specified context.
[Android.Runtime.Register(".ctor", "(Ljava/net/URL;Ljava/lang/String;)V", "")]
public URL (Java.Net.URL? context, string? spec);
[<Android.Runtime.Register(".ctor", "(Ljava/net/URL;Ljava/lang/String;)V", "")>]
new Java.Net.URL : Java.Net.URL * string -> Java.Net.URL
Parameters
- context
- URL
the context in which to parse the specification.
- spec
- String
the String
to parse as a URL.
- Attributes
Exceptions
if spec
could not be parsed as a
URL or has an unsupported protocol.
Remarks
Creates a URL by parsing the given spec within a specified context.
The new URL is created from the given context URL and the spec argument as described in RFC2396 "Uniform Resource Identifiers : Generic * Syntax" : <blockquote>
<scheme>://<authority><path>?<query>#<fragment>
</blockquote> The reference is parsed into the scheme, authority, path, query and fragment parts. If the path component is empty and the scheme, authority, and query components are undefined, then the new URL is a reference to the current document. Otherwise, the fragment and query parts present in the spec are used in the new URL.
If the scheme component is defined in the given spec and does not match the scheme of the context, then the new URL is created as an absolute URL based on the spec alone. Otherwise the scheme component is inherited from the context URL.
If the authority component is present in the spec then the spec is treated as absolute and the spec authority and path will replace the context authority and path. If the authority component is absent in the spec then the authority of the new URL will be inherited from the context.
If the spec's path component begins with a slash character "/" then the path is treated as absolute and the spec path replaces the context path.
Otherwise, the path is treated as a relative path and is appended to the context path, as described in RFC2396. Also, in this case, the path is canonicalized through the removal of directory changes made by occurrences of ".." and ".".
For a more detailed description of URL parsing, refer to RFC2396.
Java documentation for java.net.URL.URL(java.net.URL, java.lang.String)
.
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
URL(URL, String, URLStreamHandler)
Creates a URL by parsing the given spec with the specified handler within a specified context.
[Android.Runtime.Register(".ctor", "(Ljava/net/URL;Ljava/lang/String;Ljava/net/URLStreamHandler;)V", "")]
public URL (Java.Net.URL? context, string? spec, Java.Net.URLStreamHandler? handler);
[<Android.Runtime.Register(".ctor", "(Ljava/net/URL;Ljava/lang/String;Ljava/net/URLStreamHandler;)V", "")>]
new Java.Net.URL : Java.Net.URL * string * Java.Net.URLStreamHandler -> Java.Net.URL
Parameters
- context
- URL
the context in which to parse the specification.
- spec
- String
the String
to parse as a URL.
- handler
- URLStreamHandler
the stream handler for the URL.
- Attributes
Exceptions
if the given string spec
could not
be parsed as a URL or an invalid protocol has been found.
Remarks
Creates a URL by parsing the given spec with the specified handler within a specified context. If the handler is null, the parsing occurs as with the two argument constructor.
Java documentation for java.net.URL.URL(java.net.URL, java.lang.String, java.net.URLStreamHandler)
.
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
URL(String, String, String)
Creates a URL from the specified protocol
name, host
name, and file
name.
[Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "")]
public URL (string? protocol, string? host, string? file);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "")>]
new Java.Net.URL : string * string * string -> Java.Net.URL
Parameters
- protocol
- String
the name of the protocol to use.
- host
- String
the name of the host.
- file
- String
the file on the host.
- Attributes
Exceptions
if the combination of all arguments do not represent a valid URL or if the protocol is invalid.
Remarks
Creates a URL from the specified protocol
name, host
name, and file
name. The default port for the specified protocol is used.
This method is equivalent to calling the four-argument constructor with the arguments being protocol
, host
, -1
, and file
.
No validation of the inputs is performed by this constructor.
Java documentation for java.net.URL.URL(java.lang.String, java.lang.String, java.lang.String)
.
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
URL(String, String, Int32, String)
Creates a URL
object from the specified
protocol
, host
, port
number, and file
.
[Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V", "")]
public URL (string? protocol, string? host, int port, string? file);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;)V", "")>]
new Java.Net.URL : string * string * int * string -> Java.Net.URL
Parameters
- protocol
- String
the name of the protocol to use.
- host
- String
the name of the host.
- port
- Int32
the port number on the host.
- file
- String
the file on the host
- Attributes
Exceptions
if the combination of all arguments do not represent a valid URL or if the protocol is invalid.
Remarks
Creates a URL
object from the specified protocol
, host
, port
number, and file
.
host
can be expressed as a host name or a literal IP address. If IPv6 literal address is used, it should be enclosed in square brackets ('['
and ']'
), as specified by RFC 2732; However, the literal IPv6 address format defined in RFC 2373: IP Version 6 Addressing Architecturehttp://www.ietf.org/rfc/rfc2373.txt is also accepted.
Specifying a port
number of -1
indicates that the URL should use the default port for the protocol.
If this is the first URL object being created with the specified protocol, a stream protocol handler object, an instance of class URLStreamHandler
, is created for that protocol: <ol> <li>If the application has previously set up an instance of URLStreamHandlerFactory
as the stream handler factory, then the createURLStreamHandler
method of that instance is called with the protocol string as an argument to create the stream protocol handler. <li>If no URLStreamHandlerFactory
has yet been set up, or if the factory's createURLStreamHandler
method returns null
, then the constructor finds the value of the system property: <blockquote>
java.protocol.handler.pkgs
</blockquote> If the value of that system property is not null
, it is interpreted as a list of packages separated by a vertical slash character '|
'. The constructor tries to load the class named: <blockquote>
<<i>package</i>>.<<i>protocol</i>>.Handler
</blockquote> where <package> is replaced by the name of the package and <protocol> is replaced by the name of the protocol. If this class does not exist, or if the class exists but it is not a subclass of URLStreamHandler
, then the next package in the list is tried. <li>If the previous step fails to find a protocol handler, then the constructor tries to load from a system default package. <blockquote>
<<i>system default package</i>>.<<i>protocol</i>>.Handler
</blockquote> If this class does not exist, or if the class exists but it is not a subclass of URLStreamHandler
, then a MalformedURLException
is thrown. </ol>
Protocol handlers for the following protocols are guaranteed to exist on the search path :- <blockquote>
http, https, file, and jar
</blockquote> Protocol handlers for additional protocols may also be available.
No validation of the inputs is performed by this constructor.
Java documentation for java.net.URL.URL(java.lang.String, java.lang.String, int, java.lang.String)
.
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
URL(String, String, Int32, String, URLStreamHandler)
Creates a URL
object from the specified
protocol
, host
, port
number, file
, and handler
.
[Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/net/URLStreamHandler;)V", "")]
public URL (string? protocol, string? host, int port, string? file, Java.Net.URLStreamHandler? handler);
[<Android.Runtime.Register(".ctor", "(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;Ljava/net/URLStreamHandler;)V", "")>]
new Java.Net.URL : string * string * int * string * Java.Net.URLStreamHandler -> Java.Net.URL
Parameters
- protocol
- String
the name of the protocol to use.
- host
- String
the name of the host.
- port
- Int32
the port number on the host.
- file
- String
the file on the host
- handler
- URLStreamHandler
the stream handler for the URL.
- Attributes
Exceptions
if the combination of all arguments do not represent a valid URL or if the protocol is invalid.
Remarks
Creates a URL
object from the specified protocol
, host
, port
number, file
, and handler
. Specifying a port
number of -1
indicates that the URL should use the default port for the protocol. Specifying a handler
of null
indicates that the URL should use a default stream handler for the protocol, as outlined for: java.net.URL#URL(java.lang.String, java.lang.String, int, java.lang.String)
If the handler is not null and there is a security manager, the security manager's checkPermission
method is called with a NetPermission("specifyStreamHandler")
permission. This may result in a SecurityException.
No validation of the inputs is performed by this constructor.
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.