An InputStream can be opened for every resource if it exists in physical form, but a URL or File handle can just be returned for certain resources. The actual behavior is implementation-specific.
getInputStream(), getURL(), getURI(), getFile(), WritableResource, ContextResource, UrlResource, FileUrlResource, FileSystemResource, ClassPathResource, ByteArrayResource, InputStreamResource
| Modifier and Type | Method and Description |
|---|---|
| public long | |
| public Resource | Returns: the resource handle for the relative resourcethe relative path (relative to this resource) relativePath)Create a resource relative to this resource. |
| public boolean | |
| public default byte[] | Returns: the contents of this resource as byte arrayReturn the contents of this resource as a byte array. |
| public default String | Returns: the contents of this resource as aStringthe charset to use for decoding charset)Return the contents of this resource as a string, using the specified charset. |
| public String | getDescription()
Return a description for this resource, to be used for error output when working with the resource. |
| public File | |
| public String | getFilename()
Determine the filename for this resource — typically the last
part of the path — for example, |
| public URI | |
| public URL | |
| public default boolean | |
| public default boolean | |
| public default boolean | |
| public long | |
| public default ReadableByteChannel | Returns: the byte channel for the underlying resource (must not benull)Return a |
| contentLength | back to summary |
|---|---|
| public long contentLength() throws IOException Determine the content length for this resource.
| |
| createRelative | back to summary |
|---|---|
| public Resource createRelative(String relativePath) throws IOException Create a resource relative to this resource.
| |
| exists | back to summary |
|---|---|
| public boolean exists() Determine whether this resource actually exists in physical form. This method performs a definitive existence check, whereas the
existence of a | |
| getContentAsByteArray | back to summary |
|---|---|
| public default byte[] getContentAsByteArray() throws IOException Return the contents of this resource as a byte array.
| |
| getContentAsString | back to summary |
|---|---|
| public default String getContentAsString(Charset charset) throws IOException Return the contents of this resource as a string, using the specified charset.
| |
| getDescription | back to summary |
|---|---|
| public String getDescription() Return a description for this resource, to be used for error output when working with the resource. Implementations are also encouraged to return this value
from their
| |
| getFile | back to summary |
|---|---|
| public File getFile() throws IOException Return a File handle for this resource.
| |
| getFilename | back to summary |
|---|---|
| public String getFilename() Determine the filename for this resource — typically the last
part of the path — for example, Returns Implementations are encouraged to return the filename unencoded.
| |
| getURI | back to summary |
|---|---|
| public URI getURI() throws IOException Return a URI handle for this resource.
| |
| getURL | back to summary |
|---|---|
| public URL getURL() throws IOException Return a URL handle for this resource.
| |
| isFile | back to summary |
|---|---|
| public default boolean isFile() Determine whether this resource represents a file in a file system. A value of This is conservatively
| |
| isOpen | back to summary |
|---|---|
| public default boolean isOpen() Indicate whether this resource represents a handle with an open stream.
If Will be | |
| isReadable | back to summary |
|---|---|
| public default boolean isReadable() Indicate whether non-empty contents of this resource can be read via
Will be
| |
| lastModified | back to summary |
|---|---|
| public long lastModified() throws IOException Determine the last-modified timestamp for this resource.
| |
| readableChannel | back to summary |
|---|---|
| public default ReadableByteChannel readableChannel() throws IOException Return a It is expected that each call creates a fresh channel. The default implementation returns
| |