类 FileUrlResource
- 所有已实现的接口:
InputStreamSource,OutputStreamSource,Resource,WritableResource,ThrowingConsumer<OutputStream>,Consumer<OutputStream>
UrlResource which assumes file resolution, to the degree
of implementing the WritableResource interface for it. This resource
variant also caches resolved File handles from getFile().
This is the class resolved by DefaultResourceLoader for a "file:..."
URL location, allowing a downcast to WritableResource for it.
Alternatively, for direct construction from a File handle
or NIO Path, consider using FileSystemResource.
- 从以下版本开始:
- 4.0 2021/12/30 21:39
- 作者:
- Juergen Hoeller, Harry Yang
-
字段概要
字段从接口继承的字段 cn.taketoday.core.io.Resource
EMPTY_ARRAY -
构造器概要
构造器构造器说明FileUrlResource(String location) Create a newFileUrlResourcebased on the given file location, using the URL protocol "file".FileUrlResource(URL url) Create a newFileUrlResourcebased on the given URL object. -
方法概要
修饰符和类型方法说明createRelative(String relativePath) This implementation creates aUrlResource, delegating toUrlResource.createRelativeURL(String)for adapting the relative path.getFile()This implementation returns a File reference for the underlying URL/URI, provided that it refers to a file in the file system.Return anOutputStreamfor the underlying resource, allowing to (over-)write its content.booleanTests whether the resource denoted by this abstract pathname is a directory.booleanIndicate whether the contents of this resource can be written viaOutputStreamSource.getOutputStream().Return aWritableByteChannel.从类继承的方法 cn.taketoday.core.io.UrlResource
createRelativeURL, customizeConnection, equals, from, from, getInputStream, getName, getURI, getURL, hashCode, isFile, toString从类继承的方法 cn.taketoday.core.io.AbstractFileResolvingResource
checkReadable, contentLength, customizeConnection, exists, getFile, getFileForLastModifiedCheck, isFile, isReadable, lastModified, readableChannel从类继承的方法 cn.taketoday.core.io.AbstractResource
isOpen, list, list从接口继承的方法 cn.taketoday.core.io.InputStreamSource
acceptWithException, getInputStream, getReader, getReader, readableChannel, transferTo从接口继承的方法 cn.taketoday.core.io.OutputStreamSource
getWriter从接口继承的方法 cn.taketoday.core.io.Resource
contentLength, exists, getContentAsByteArray, getContentAsString, getName, getURI, getURL, isFile, isOpen, isReadable, lastModified, list, list, toString从接口继承的方法 cn.taketoday.util.function.ThrowingConsumer
accept, accept, throwing
-
字段详细资料
-
file
-
-
构造器详细资料
-
FileUrlResource
Create a newFileUrlResourcebased on the given URL object.Note that this does not enforce "file" as URL protocol. If a protocol is known to be resolvable to a file, it is acceptable for this purpose.
- 参数:
url- a URL- 另请参阅:
-
FileUrlResource
Create a newFileUrlResourcebased on the given file location, using the URL protocol "file".The given parts will automatically get encoded if necessary.
- 参数:
location- the location (i.e. the file path within that protocol)- 抛出:
MalformedURLException- if the given URL specification is not valid- 另请参阅:
-
-
方法详细资料
-
getFile
从类复制的说明:UrlResourceThis implementation returns a File reference for the underlying URL/URI, provided that it refers to a file in the file system.- 指定者:
getFile在接口中Resource- 覆盖:
getFile在类中UrlResource- 抛出:
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- 另请参阅:
-
isDirectory
从接口复制的说明:ResourceTests whether the resource denoted by this abstract pathname is a directory.Where it is required to distinguish an I/O exception from the case that the file is not a directory, or where several attributes of the same file are required at the same time, then the
Files.readAttributesmethod may be used.- 指定者:
isDirectory在接口中Resource- 覆盖:
isDirectory在类中AbstractResource- 返回:
trueif and only if the file denoted by this abstract pathname exists and is a directory;falseotherwise- 抛出:
IOException- cannot determine resource
-
isWritable
public boolean isWritable()从接口复制的说明:WritableResourceIndicate whether the contents of this resource can be written viaOutputStreamSource.getOutputStream().Will be
truefor typical resource descriptors; note that actual content writing may still fail when attempted. However, a value offalseis a definitive indication that the resource content cannot be modified. -
getOutputStream
从接口复制的说明:OutputStreamSourceReturn anOutputStreamfor the underlying resource, allowing to (over-)write its content.- 指定者:
getOutputStream在接口中OutputStreamSource- 抛出:
IOException- if the stream could not be opened
-
writableChannel
从接口复制的说明:OutputStreamSourceReturn aWritableByteChannel.It is expected that each call creates a fresh channel.
The default implementation returns
Channels.newChannel(OutputStream)with the result ofOutputStreamSource.getOutputStream().- 指定者:
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- 另请参阅:
-
createRelative
从类复制的说明:UrlResourceThis implementation creates aUrlResource, delegating toUrlResource.createRelativeURL(String)for adapting the relative path.- 指定者:
createRelative在接口中Resource- 覆盖:
createRelative在类中UrlResource- 参数:
relativePath- the relative path (relative to this resource)- 返回:
- the resource handle for the relative resource
- 抛出:
MalformedURLException- 另请参阅:
-