类 PathResource
- 所有已实现的接口:
InputStreamSource,OutputStreamSource,Resource,WritableResource
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.
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.
- 从以下版本开始:
- 4.0 2022/3/25 11:45
- 作者:
- Philippe Marschall, Juergen Hoeller, Harry Yang
- 另请参阅:
-
字段概要
从接口继承的字段 cn.taketoday.core.io.Resource
EMPTY_ARRAY -
构造器概要
构造器构造器说明PathResource(String path) Create a new PathResource from a Path handle.PathResource(URI uri) Create a new PathResource from a Path handle.PathResource(Path path) Create a new PathResource from a Path handle. -
方法概要
修饰符和类型方法说明longThis implementation returns the underlying file's length.createRelative(String relativePath) This implementation creates a PathResource, applying the given path relative to the path of the underlying file of this resource descriptor.booleanThis implementation compares the underlying Path references.booleanexists()This implementation returns whether the underlying file exists.getFile()This implementation returns the underlying File reference.This implementation opens a InputStream for the underlying file.getName()This implementation returns the name of the file.This implementation opens a OutputStream for the underlying file.final StringgetPath()Return the file path for this resource.getURI()This implementation returns a URI for the underlying file.getURL()This implementation returns a URL for the underlying file.inthashCode()This implementation returns the hash code of the underlying Path reference.booleanisFile()This implementation always indicates a file.booleanThis implementation checks whether the underlying file is marked as readable (and corresponds to an actual file with content, not to a directory).booleanThis implementation checks whether the underlying file is marked as writable (and corresponds to an actual file with content, not to a directory).longThis implementation returns the underlying File's timestamp.This implementation opens a Channel for the underlying file.toString()Return a description for this resource, to be used for error output when working with the resource.This implementation opens a Channel for the underlying file.从类继承的方法 cn.taketoday.core.io.AbstractResource
customizeConnection, customizeConnection, getFileForLastModifiedCheck, isDirectory, isOpen, list, list从接口继承的方法 cn.taketoday.core.io.InputStreamSource
getReader, getReader从接口继承的方法 cn.taketoday.core.io.OutputStreamSource
getWriter从接口继承的方法 cn.taketoday.core.io.Resource
isDirectory, isOpen, list, list
-
构造器详细资料
-
PathResource
Create a new PathResource from a Path handle.Note: Unlike
FileSystemResource, when building relative resources viacreateRelative(java.lang.String), the relative path will be built underneath the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" → "C:/dir1/dir2"!- 参数:
path- a Path handle
-
PathResource
Create a new PathResource from a Path handle.Note: Unlike
FileSystemResource, when building relative resources viacreateRelative(java.lang.String), the relative path will be built underneath the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" → "C:/dir1/dir2"!- 参数:
path- a path- 另请参阅:
-
PathResource
Create a new PathResource from a Path handle.Note: Unlike
FileSystemResource, when building relative resources viacreateRelative(java.lang.String), the relative path will be built underneath the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" → "C:/dir1/dir2"!- 参数:
uri- a path URI- 另请参阅:
-
-
方法详细资料
-
getPath
Return the file path for this resource. -
exists
public boolean exists()This implementation returns whether the underlying file exists.- 指定者:
exists在接口中Resource- 覆盖:
exists在类中AbstractResource- 另请参阅:
-
isReadable
public boolean isReadable()This implementation checks whether the underlying file is marked as readable (and corresponds to an actual file with content, not to a directory). -
getInputStream
This implementation opens a InputStream for the underlying file.- 指定者:
getInputStream在接口中InputStreamSource- 返回:
- input stream of
Resourcecontent - 抛出:
IOException- If an input exception occurs- 另请参阅:
-
isWritable
public boolean isWritable()This implementation checks whether the underlying file is marked as writable (and corresponds to an actual file with content, not to a directory). -
getOutputStream
This implementation opens a OutputStream for the underlying file.- 指定者:
getOutputStream在接口中OutputStreamSource- 抛出:
IOException- if the stream could not be opened- 另请参阅:
-
getURL
This implementation returns a URL for the underlying file.- 指定者:
getURL在接口中Resource- 覆盖:
getURL在类中AbstractResource- 抛出:
IOException- if the resource cannot be resolved as URL, i.e. if the resource is not available as a descriptor- 另请参阅:
-
getURI
This implementation returns a URI for the underlying file.- 指定者:
getURI在接口中Resource- 覆盖:
getURI在类中AbstractResource- 抛出:
IOException- if the resource cannot be resolved as URI, i.e. if the resource is not available as a descriptor- 另请参阅:
-
isFile
public boolean isFile()This implementation always indicates a file.- 指定者:
isFile在接口中Resource- 覆盖:
isFile在类中AbstractResource- 另请参阅:
-
getFile
This implementation returns the underlying File reference.- 指定者:
getFile在接口中Resource- 覆盖:
getFile在类中AbstractResource- 抛出:
FileNotFoundException- if the resource cannot be resolved as absolute file path, i.e. if the resource is not available in a file systemIOException- in case of general resolution/reading failures- 另请参阅:
-
readableChannel
This implementation opens a Channel for the underlying file.- 指定者:
readableChannel在接口中InputStreamSource- 返回:
- the byte channel for the underlying resource (must not be
null) - 抛出:
FileNotFoundException- if the underlying resource doesn't existIOException- if the content channel could not be opened- 另请参阅:
-
writableChannel
This implementation opens a Channel for the underlying file.- 指定者:
writableChannel在接口中OutputStreamSource- 返回:
- the byte channel for the underlying resource (must not be
null) - 抛出:
FileNotFoundException- if the underlying resource doesn't existIOException- if the content channel could not be opened- 另请参阅:
-
contentLength
This implementation returns the underlying file's length.- 指定者:
contentLength在接口中Resource- 覆盖:
contentLength在类中AbstractResource- 抛出:
IOException- if the resource cannot be resolved (in the file system or as some other known physical resource type)- 另请参阅:
-
lastModified
This implementation returns the underlying File's timestamp.- 指定者:
lastModified在接口中Resource- 覆盖:
lastModified在类中AbstractResource- 抛出:
IOException- if the resource cannot be resolved (in the file system or as some other known physical resource type)- 另请参阅:
-
createRelative
This implementation creates a PathResource, applying the given path relative to the path of the underlying file of this resource descriptor.- 指定者:
createRelative在接口中Resource- 覆盖:
createRelative在类中AbstractResource- 参数:
relativePath- the relative path (relative to this resource)- 返回:
- the resource handle for the relative resource
- 另请参阅:
-
getName
This implementation returns the name of the file.- 指定者:
getName在接口中Resource- 覆盖:
getName在类中AbstractResource- 另请参阅:
-
toString
从接口复制的说明:ResourceReturn 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
toStringmethod.- 指定者:
toString在接口中Resource- 覆盖:
toString在类中AbstractResource- 另请参阅:
-
equals
This implementation compares the underlying Path references.- 覆盖:
equals在类中AbstractResource
-
hashCode
public int hashCode()This implementation returns the hash code of the underlying Path reference.- 覆盖:
hashCode在类中AbstractResource
-