Udostępnij za pośrednictwem


Class.GetResourceAsStream(String) Method

Definition

Finds a resource with a given name.

[Android.Runtime.Register("getResourceAsStream", "(Ljava/lang/String;)Ljava/io/InputStream;", "")]
public System.IO.Stream? GetResourceAsStream (string name);
[<Android.Runtime.Register("getResourceAsStream", "(Ljava/lang/String;)Ljava/io/InputStream;", "")>]
member this.GetResourceAsStream : string -> System.IO.Stream

Parameters

name
String

name of the desired resource

Returns

A java.io.InputStream 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#getSystemResourceAsStream.

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.getResourceAsStream(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