Finds all the resources with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.
The name of a resource is a /
-separated path name that
identifies the resource.
Resources in named modules are subject to the encapsulation rules
specified by Module.getResourceAsStream
.
Additionally, and except for the special case where the resource has a
name ending with " .class
", this method will only find resources in
packages of named modules when the package is Module.isOpen(String)
unconditionally (even if the caller of this method is in the
same module as the resource).
name
| The resource name |
URL
objects for
the resource. If no resources could be found, the enumeration
will be empty. Resources for which a URL
cannot be
constructed, are in package that is not opened unconditionally,
or access to the resource is denied by the security manager,
are not returned in the enumeration.
IOException
| If I/O errors occur | |
NullPointerException | If name is null |
@implSpec The default implementation will first search the parent class
loader for the resource; if the parent is null
the path of the
class loader built into the virtual machine is searched. It then
invokes findResources(String)
to find the resources with the
name in this class loader. It returns an enumeration whose elements
are the URLs found by searching the parent class loader followed by
the elements found with findResources
.
@apiNote Where several modules are defined to the same class loader,
and where more than one module contains a resource with the given name,
then the ordering is not specified and may be very unpredictable.
When overriding this method it is recommended that an
implementation ensures that any delegation is consistent with the getResource(String)
method. This should
ensure that the first element returned by the Enumeration's
nextElement
method is the same resource that the
getResource(String)
method would return.
@revised 9
@spec JPMS
Diagram: ClassLoader