Aracılığıyla paylaş


Class.GetResource(String) Method

Definition

Finds a resource with a given name.

[Android.Runtime.Register("getResource", "(Ljava/lang/String;)Ljava/net/URL;", "")]
public Java.Net.URL? GetResource (string name);
[<Android.Runtime.Register("getResource", "(Ljava/lang/String;)Ljava/net/URL;", "")>]
member this.GetResource : string -> Java.Net.URL

Parameters

name
String

name of the desired resource

Returns

URL

A java.net.URL object; null if no resource with this name is found.

Attributes

Remarks

Finds a resource with a given name.

The rules for searching resources associated with a given class are implemented by the defining ClassLoader class loader of the class. This method delegates to this object's class loader. If this object was loaded by the bootstrap class loader, the method delegates to ClassLoader#getSystemResource.

Before delegation, an absolute resource name is constructed from the given resource name using this algorithm:

<ul>

<li> If the name begins with a '/' ('&#92;u002f'), then the absolute name of the resource is the portion of the name following the '/'.

<li> Otherwise, the absolute name is of the following form:

<blockquote> modified_package_name/name</blockquote>

Where the modified_package_name is the package name of this object with '/' substituted for '.' ('&#92;u002e').

</ul>

Added in 1.1.

Java documentation for java.lang.Class.getResource(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

See also