类 FileUrlResource
- 所有已实现的接口:
InputStreamSource,Resource,WritableResource
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.
- 从以下版本开始:
- 5.0.2
- 作者:
- Juergen Hoeller
-
构造器概要
构造器构造器说明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.booleanIndicate whether the contents of this resource can be written viaWritableResource.getOutputStream().Return aWritableByteChannel.从类继承的方法 com.alibaba.nacos.common.packagescan.resource.UrlResource
createRelativeUrl, equals, getDescription, getFilename, getInputStream, getUri, getUrl, hashCode, isFile从类继承的方法 com.alibaba.nacos.common.packagescan.resource.AbstractFileResolvingResource
contentLength, customizeConnection, customizeConnection, exists, getFile, getFileForLastModifiedCheck, isFile, isReadable, lastModified, readableChannel从类继承的方法 com.alibaba.nacos.common.packagescan.resource.AbstractResource
isOpen, toString从接口继承的方法 com.alibaba.nacos.common.packagescan.resource.InputStreamSource
getInputStream从接口继承的方法 com.alibaba.nacos.common.packagescan.resource.Resource
contentLength, exists, getDescription, getFilename, getUri, getUrl, isFile, isOpen, isReadable, lastModified, readableChannel
-
构造器详细资料
-
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- 另请参阅:
-
isWritable
public boolean isWritable()从接口复制的说明:WritableResourceIndicate whether the contents of this resource can be written viaWritableResource.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
从接口复制的说明:WritableResourceReturn anOutputStreamfor the underlying resource, allowing to (over-)write its content.- 指定者:
getOutputStream在接口中WritableResource- 抛出:
IOException- if the stream could not be opened- 另请参阅:
-
writableChannel
从接口复制的说明:WritableResourceReturn aWritableByteChannel.It is expected that each call creates a fresh channel.
The default implementation returns
Channels.newChannel(OutputStream)with the result ofWritableResource.getOutputStream().- 指定者:
writableChannel在接口中WritableResource- 返回:
- 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- 另请参阅:
-