Resource implementation for java.nio.file.Path handles,
performing all operations and transformations via the Path API.
Supports resolution as a File and also as a URL.
Implements the extended WritableResource interface.Note
As of 5.1, java. support is also available
in FileSystemResource,
applying Spring's standard String-based path transformations but
performing all operations via the java. API.
This PathResource is effectively a pure java.nio.path.Path
based alternative with different createRelative behavior.
java.nio.file.Path , java.nio.file.Files , FileSystemResource
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public long | contentLength()
Overrides org. Implements org. |
| public Resource | createRelative(String
the relative path (relative to this resource) relativePath)Overrides org. Implements org. PathResource, applying the given path
relative to the path of the underlying file of this resource descriptor.
|
| public boolean | equals(Object
the reference object with which to compare. other)Overrides org. Path references.
|
| public boolean | exists()
Overrides org. Implements org. |
| public byte[] | getContentAsByteArray()
Overrides default org. |
| public String | getContentAsString(Charset
the charset to use for decoding charset)Overrides default org. |
| public String | getDescription()
Implements org. |
| public File | getFile()
Overrides org. Implements org. File reference.
|
| public String | getFilename()
Overrides org. Implements org. |
| public InputStream | getInputStream()
Implements org. InputStream for the underlying file.
|
| public OutputStream | getOutputStream()
Implements org. OutputStream for the underlying file.
|
| public final String | |
| public URI | getURI()
Overrides org. Implements org. URI for the underlying file.
|
| public URL | getURL()
Overrides org. Implements org. URL for the underlying file.
|
| public int | hashCode()
Overrides org. Path reference.
|
| public boolean | isFile()
Overrides org. Overrides default org. |
| public boolean | isReadable()
Overrides org. Overrides default org. |
| public boolean | isWritable()
Overrides default org. |
| public long | lastModified()
Overrides org. Implements org. |
| public ReadableByteChannel | readableChannel()
Overrides org. Overrides default org. ReadableByteChannel for the underlying file.
|
| public WritableByteChannel | writableChannel()
Overrides default org. WritableByteChannel for the underlying file.
|
| path | back to summary |
|---|---|
| private final Path path | |
| PathResource | back to summary |
|---|---|
| public PathResource(Path path) Create a new Note Unlike
| |
| PathResource | back to summary |
|---|---|
| public PathResource(String path) Create a new Note Unlike
| |
| PathResource | back to summary |
|---|---|
| public PathResource(URI uri) Create a new Note Unlike
| |
| contentLength | back to summary |
|---|---|
| public long contentLength() throws IOException Overrides org. Implements org. This implementation returns the underlying file's length.
| |
| createRelative | back to summary |
|---|---|
| public Resource createRelative(String relativePath) Overrides org. Implements org. This implementation creates a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides org. This implementation compares the underlying
| |
| exists | back to summary |
|---|---|
| public boolean exists() Overrides org. Implements org. This implementation returns whether the underlying file exists.
| |
| getContentAsByteArray | back to summary |
|---|---|
| public byte[] getContentAsByteArray() throws IOException Overrides default org. Doc from org. Return the contents of this resource as a byte array.
| |
| getContentAsString | back to summary |
|---|---|
| public String getContentAsString(Charset charset) throws IOException Overrides default org. Doc from org. Return the contents of this resource as a string, using the specified charset.
| |
| getDescription | back to summary |
|---|---|
| public String getDescription() Implements org. Doc from org. 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 Overrides org. Implements org. This implementation returns the underlying
| |
| getFilename | back to summary |
|---|---|
| public String getFilename() Overrides org. Implements org. This implementation returns the name of the file.
| |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream() throws IOException Implements org. This implementation opens an
| |
| getOutputStream | back to summary |
|---|---|
| public OutputStream getOutputStream() throws IOException Implements org. This implementation opens an
| |
| getPath | back to summary |
|---|---|
| public final String getPath() Return the file path for this resource. | |
| getURI | back to summary |
|---|---|
| public URI getURI() throws IOException Overrides org. Implements org. This implementation returns a
| |
| getURL | back to summary |
|---|---|
| public URL getURL() throws IOException Overrides org. Implements org. This implementation returns a
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides org. This implementation returns the hash code of the underlying
| |
| isFile | back to summary |
|---|---|
| public boolean isFile() Overrides org. Overrides default org. This implementation always indicates a file.
| |
| isReadable | back to summary |
|---|---|
| public boolean isReadable() Overrides org. Overrides default org. This implementation checks whether the underlying file is marked as readable (and corresponds to an actual file with content, not to a directory). | |
| isWritable | back to summary |
|---|---|
| public boolean isWritable() Overrides default org. This implementation checks whether the underlying file is marked as writable (and corresponds to an actual file with content, not to a directory). | |
| lastModified | back to summary |
|---|---|
| public long lastModified() throws IOException Overrides org. Implements org. This implementation returns the underlying file's timestamp.
| |
| readableChannel | back to summary |
|---|---|
| public ReadableByteChannel readableChannel() throws IOException Overrides org. Overrides default org. This implementation opens a
| |
| writableChannel | back to summary |
|---|---|
| public WritableByteChannel writableChannel() throws IOException Overrides default org. This implementation opens a
| |