| Modifier and Type | Field and Description |
|---|---|
| protected ByteBuffer | byteBuffer
The byte buffer, or null. |
| private final ClasspathElement | classpathElement
The classpath element this resource was obtained from. |
| protected InputStream | inputStream
The input stream, or null. |
| protected long | length
The length, or -1L for unknown. |
| pack-priv LogNode | |
| private String | toString
The cached result of toString(). |
| Access | Constructor and Description |
|---|---|
| public | Resource(final ClasspathElement
the classpath element this resource was obtained from. classpathElement, final long the length the length of the resource. length)Constructor. |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements java. Close the underlying InputStream, or release/unmap the underlying ByteBuffer. |
| public int | Returns: the intthe o o)Implements java. Compare to. |
| public boolean | Returns: true, if successfulthe obj obj)Overrides java. Equals. |
| public File | Returns: TheFile for the classpath element package root dir or jar that this Resource was
found within, or null if this Resource was found in a module backed by a "jrt:" URI, or a
module with an unknown location. May also return null if the classpath element was an http/https URL,
and the jar was downloaded directly to RAM, rather than to a temp file on disk (e.g. if the temp dir
is not writeable).Get the classpath element |
| public URI | Returns: TheURL of the classpath element or module that this resource was found within.Get the |
| public URL | Returns: TheURL of the classpath element or module that this resource was found within.Get the |
| public String | Returns: the content of thisResource as a String.Convenience method to get the content of this |
| public abstract long | Returns: The millis since the epoch indicating the date / time that this file resource was last modified. Returns 0L if the last modified date is unknown.Get the last modified time for the resource, in milliseconds since the epoch. |
| public long | Returns: The length of the resource. This only reliably returns a valid value after callingopen(),
read(), or load() (and for open(), only if the underlying jarfile has
length information for corresponding ZipEntry -- some jarfiles may not have length
information in their zip entries). Returns -1L if the length is unknown.Get the length of the resource. |
| public ModuleRef | |
| public abstract String | Returns: the path of this classpath resource relative to the package root. For example, for a resource path of"BOOT-INF/classes/com/xyz/resource.xml" and a package root of "BOOT-INF/classes/",
returns "com/xyz/resource.xml". Also drops version prefixes for multi-version jars, for
example for a resource path of "META-INF/versions/11/com/xyz/resource.xml" while running on
JDK 9+, returns "com/xyz/resource.xml".Get the path of this classpath resource relative to the package root. |
| public String | Returns: the full path of this classpath resource within the classpath element. For example, will return the full path of"BOOT-INF/classes/com/xyz/resource.xml" or
"META-INF/versions/11/com/xyz/resource.xml", not "com/xyz/resource.xml".Get the full path of this classpath resource relative to the root of the classpath element. |
| public abstract Set | Returns: The set ofPosixFilePermission permission flags for the resource, or null if unknown.Get the POSIX file permissions for the resource. |
| public URI | |
| public URL | |
| public int | |
| public abstract byte[] | Returns: The contents of the resource file.Load a classpath resource and return its content as a byte array. |
| public abstract InputStream | |
| pack-priv abstract ClassfileReader | Returns: theClassfileReader.Open a |
| public abstract ByteBuffer | Returns: The allocated or mappedByteBuffer for the resource file content.Open a |
| public CloseableByteBuffer | Returns: The allocated or mappedByteBuffer for the resource file content.Open a |
| public String | Returns: the resource location as a URL String.Overrides java. Get a string representation of the resource's location (as a URL string). |
| private static URL |
| byteBuffer | back to summary |
|---|---|
| protected ByteBuffer byteBuffer The byte buffer, or null. | |
| classpathElement | back to summary |
|---|---|
| private final ClasspathElement classpathElement The classpath element this resource was obtained from. | |
| inputStream | back to summary |
|---|---|
| protected InputStream inputStream The input stream, or null. | |
| length | back to summary |
|---|---|
| protected long length The length, or -1L for unknown. | |
| scanLog | back to summary |
|---|---|
| pack-priv LogNode scanLog The | |
| toString | back to summary |
|---|---|
| private String toString The cached result of toString(). | |
| Resource | back to summary |
|---|---|
| public Resource(final ClasspathElement classpathElement, final long length) Constructor.
| |
| close | back to summary |
|---|---|
| public void close() Implements java. Close the underlying InputStream, or release/unmap the underlying ByteBuffer.
| |
| compareTo | back to summary |
|---|---|
| public int compareTo(final Resource o) Implements java. Compare to. | |
| equals | back to summary |
|---|---|
| public boolean equals(final Object obj) Overrides java. Equals. | |
| getClasspathElementFile | back to summary |
|---|---|
| public File getClasspathElementFile() Get the classpath element
| |
| getClasspathElementURI | back to summary |
|---|---|
| public URI getClasspathElementURI() Get the
| |
| getClasspathElementURL | back to summary |
|---|---|
| public URL getClasspathElementURL() Get the
| |
| getContentAsString | back to summary |
|---|---|
| public String getContentAsString() throws IOException Convenience method to get the content of this
| |
| getLastModified | back to summary |
|---|---|
| public abstract long getLastModified() Get the last modified time for the resource, in milliseconds since the epoch. This time is obtained from the directory entry, if this resource is a file on disk, or from the zipfile central directory, if this resource is a zipfile entry. Timestamps are not available for resources obtained from system modules or jlink'd modules. Note The ZIP format has no notion of timezone, so timestamps are only meaningful if it is known what timezone they were created in. We arbitrarily assume that zipfile timestamps are in the UTC timezone. This may be a wrong assumption, so you may need to apply a timezone correction if you know the timezone used by the zipfile creator.
| |
| getLength | back to summary |
|---|---|
| public long getLength() Get the length of the resource.
| |
| getModuleRef | back to summary |
|---|---|
| public ModuleRef getModuleRef() Get the The | |
| getPath | back to summary |
|---|---|
| public abstract String getPath() Get the path of this classpath resource relative to the package root.
| |
| getPathRelativeToClasspathElement | back to summary |
|---|---|
| public String getPathRelativeToClasspathElement() Get the full path of this classpath resource relative to the root of the classpath element.
| |
| getPosixFilePermissions | back to summary |
|---|---|
| public abstract Set Get the POSIX file permissions for the resource. POSIX file permissions are obtained from the directory entry, if this resource is a file on disk, or from the zipfile central directory, if this resource is a zipfile entry. POSIX file permissions are not available for resources obtained from system modules or jlink'd modules, and may not be available on non-POSIX-compliant operating systems or non-POSIX filesystems.
| |
| getURI | back to summary |
|---|---|
| public URI getURI() Get the
| |
| getURL | back to summary |
|---|---|
| public URL getURL() Get the
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Hash code.
| |
| load | back to summary |
|---|---|
| public abstract byte[] load() throws IOException Load a classpath resource and return its content as a byte array. Automatically calls
| |
| open | back to summary |
|---|---|
| public abstract InputStream open() throws IOException Open an
| |
| openClassfile | back to summary |
|---|---|
| pack-priv abstract ClassfileReader openClassfile() throws IOException Open a
| |
| read | back to summary |
|---|---|
| public abstract ByteBuffer read() throws IOException Open a
| |
| readCloseable | back to summary |
|---|---|
| public CloseableByteBuffer readCloseable() throws IOException Open a
Call
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Get a string representation of the resource's location (as a URL string). | |
| uriToURL | back to summary |
|---|---|
| private static URL uriToURL(final URI uri) Convert a URI to URL, catching "jrt:" URIs as invalid.
| |