Finds a resource with a given name.
If this class is in a named Module then this method
will attempt to find the resource in the module. This is done by
delegating to the module's class loader findResource(String,String)
method, invoking it with the module name and the absolute name of the
resource. Resources in named modules are subject to the rules for
encapsulation specified in the Module getResourceAsStream method and so this
method returns null when the resource is a
non-" .class" resource in a package that is not open to the
caller's module.
Otherwise, if this class is not in a named module then the rules for
searching resources associated with a given class are implemented by the
defining 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:
name begins with a '/'
('\u002f'), then the absolute name of the resource is the
portion of the name following the '/'.
modified_package_name/name
Where the modified_package_name is the package name of this
object with '/' substituted for '.'
('\u002e').
name | name of the desired resource |
java.io.InputStream object; null if no
resource with this name is found, the resource is in a package
that is not open to at
least the caller module, or access to the resource is denied
by the security manager.
NullPointerException | If name is null |
Module.getResourceAsStream(String)
@revised 9
@spec JPMS
Diagram: Class, Package, Module