This interface can be used by some classloader implementations to find the data for loading classes or retrieving resources.
This interface is RMI compatible, and was primarily defined to allow class loading in an RMI compatible way.
Instances of this interface may hold unmanaged data, therefore clients should close() them when no longer used.
public default void | close() Closes this stream and releases any system resources associated
with it. |
public default ByteArrayRegion | getClassBytes( Gets the bytes of the class denoted by the given binary name. |
public Supplier< | getResource( Gets a supplier for an existing resource stream specified by the given name. |
public default ByteSource | getResourceAsStream( Opens a stream to the resource specified by the given name. |
public default ByteArrayRegion | getResourceBytes( Gets the bytes of a resource specified by the given name. |
public static URL | toURL( Converts the specified iterable of resources stream suppliers to an URL. |
public static URL | toURL( Converts the resource stream for a given name and resource supplier to an URL. |
As noted in AutoCloseable.close(), cases where the
close may fail require careful attention. It is strongly advised
to relinquish the underlying resources and to internally
mark the Closeable
as closed, prior to throwing
the IOException
.
null
if not found.
The name is a slash ('/'
) separated path to the resource to be found.
The opened stream by the returned supplier should be closed for each returned stream.
The returned supplier can still return null
, if there was opening error in the stream.
null
if the resource is not found.
The name is a slash ('/'
) separated path to the resource to be found.
The returned stream should be closed by the caller.
null
if not found.
The name is a slash ('/'
) separated path to the resource to be found.
Implementations of this functions should strive to be interrupt tolerant. Meaning that if they get interrupted while loading the bytes of the resources, they should store the interrupt flag, and retry the loading. After done, reinterrupt the current thread so the interrupt status is not lost.
null
if not found.The implementation creates a new URL with a custom URLStreamHandler that opens a connection, which returns an InputStream, that is backed by the first resource stream found in the argument iterable. The opened streams from the returned URLConnection should be closed by the callers.
Although the suppliers should not return null
, this method handles if they do. In which case the
next supplier will be checked to open a stream to its resource, until there are no more. If no supplier opens a
stream, an exception is thrown when the input stream is opened.
null
if the argument
is null
.The implementation creates a new URL with a custom URLStreamHandler that opens a connection, which returns an InputStream, that is backed by the opened resource streams. Every opened stream by the URLConnection should be closed.
null
if the argument is
null
.