Class PathResource

java.lang.Object
org.springframework.core.io.AbstractResource
org.springframework.core.io.PathResource
All Implemented Interfaces:
InputStreamSource, Resource, WritableResource

@Deprecated(since="7.0", forRemoval=true) public class PathResource extends AbstractResource implements WritableResource
Deprecated, for removal: This API element is subject to removal in a future version.
since 7.0 in favor of FileSystemResource
Resource implementation for 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, Path support is also available in FileSystemResource, applying Spring's standard String-based path transformations but performing all operations via the Files API. This PathResource is effectively a pure java.nio.path.Path based alternative with different createRelative behavior.

Since:
4.0
Author:
Philippe Marschall, Juergen Hoeller
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a new PathResource from a path string.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a new PathResource from a URI.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Create a new PathResource from a Path handle.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation returns the underlying file's length.
    createRelative(String relativePath)
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation creates a PathResource, applying the given path relative to the path of the underlying file of this resource descriptor.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation compares the underlying Path references.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation returns whether the underlying file exists.
    byte[]
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the contents of this resource as a byte array.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the contents of this resource as a string, using the specified charset.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return a description for this resource, to be used for error output when working with the resource.
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation returns the underlying File reference.
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation returns the name of the file.
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation returns the underlying Path reference.
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation opens an InputStream for the underlying file.
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation opens an OutputStream for the underlying file.
    final String
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the file path for this resource.
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation returns a URI for the underlying file.
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation returns a URL for the underlying file.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation returns the hash code of the underlying Path reference.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation always indicates a file.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation checks whether the underlying file is marked as readable (and corresponds to an actual file with content, not to a directory).
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation checks whether the underlying file is marked as writable (and corresponds to an actual file with content, not to a directory).
    long
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation returns the underlying file's timestamp.
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation opens a ReadableByteChannel for the underlying file.
    Deprecated, for removal: This API element is subject to removal in a future version.
    This implementation opens a WritableByteChannel for the underlying file.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface Resource

    isOpen