类 ModuleResource
- 所有已实现的接口:
InputStreamSource,Resource,ThrowingConsumer<OutputStream>,Consumer<OutputStream>
Resource implementation for Module resolution,
performing getInputStream() access via Module.getResourceAsStream(java.lang.String).
Alternatively, consider accessing resources in a module path layout via
ClassPathResource for exported resources, or specifically relative to
a Class via ClassPathResource(String, Class)
for local resolution within the containing module of that specific class.
In common scenarios, module resources will simply be transparently visible as
classpath resources and therefore do not need any special treatment at all.
- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, Sam Brannen, Harry Yang
- 另请参阅:
-
字段概要
字段从接口继承的字段 cn.taketoday.core.io.Resource
EMPTY_ARRAY -
构造器概要
构造器构造器说明ModuleResource(Module module, String path) Create a newModuleResourcefor the givenModuleand the given resource path. -
方法概要
修饰符和类型方法说明createRelative(String relativePath) Create a resource relative to this resource.booleanReturn anInputStreamfor the content of an underlying resource.final ModuleReturn theModulefor this resource.getName()Determine the filename for this resource — typically the last part of the path — for example,"myfile.txt".final StringgetPath()Return the path for this resource.inthashCode()toString()Return a description for this resource, to be used for error output when working with the resource.从类继承的方法 cn.taketoday.core.io.AbstractResource
contentLength, customizeConnection, customizeConnection, exists, getFile, getFileForLastModifiedCheck, getURI, getURL, isDirectory, isFile, isOpen, isReadable, lastModified, list, list从接口继承的方法 cn.taketoday.core.io.InputStreamSource
acceptWithException, getReader, getReader, readableChannel, transferTo从接口继承的方法 cn.taketoday.core.io.Resource
getContentAsByteArray, getContentAsString从接口继承的方法 cn.taketoday.util.function.ThrowingConsumer
accept, accept, throwing
-
字段详细资料
-
module
-
path
-
-
构造器详细资料
-
ModuleResource
Create a newModuleResourcefor the givenModuleand the given resource path.- 参数:
module- the runtime module to search withinpath- the resource path within the module
-
-
方法详细资料
-
getModule
Return theModulefor this resource. -
getPath
Return the path for this resource. -
getInputStream
从接口复制的说明:InputStreamSourceReturn anInputStreamfor the content of an underlying resource.It is expected that each call creates a fresh stream.
This requirement is particularly important when you consider an API such as JavaMail, which needs to be able to read the stream multiple times when creating mail attachments. For such a use case, it is required that each
getInputStream()call returns a fresh stream.- 返回:
- the input stream for the underlying resource (must not be
null) - 抛出:
FileNotFoundException- if the underlying resource does not existIOException- if the content stream could not be opened- 另请参阅:
-
createRelative
从接口复制的说明:ResourceCreate a resource relative to this resource.- 指定者:
createRelative在接口中Resource- 覆盖:
createRelative在类中AbstractResource- 参数:
relativePath- the relative path (relative to this resource)- 返回:
- the resource handle for the relative resource
-
getName
从类复制的说明:AbstractResourceDetermine the filename for this resource — typically the last part of the path — for example,"myfile.txt".Returns
nullif this type of resource does not have a filename.Implementations are encouraged to return the filename unencoded.
- 指定者:
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
- 覆盖:
equals在类中AbstractResource
-
hashCode
public int hashCode()- 覆盖:
hashCode在类中AbstractResource
-