类 AbstractFileResolvingResource
java.lang.Object
cn.taketoday.core.io.AbstractResource
cn.taketoday.core.io.AbstractFileResolvingResource
- 所有已实现的接口:
InputStreamSource,Resource
- 直接已知子类:
ClassPathResource,UrlResource
Abstract base class for resources which resolve URLs into File references,
such as
UrlResource or ClassPathResource.
Detects the "file" protocol as well as the JBoss "vfs" protocol in URLs, resolving file system references accordingly.
- 从以下版本开始:
- 4.0 2022/2/20 16:28
- 作者:
- Juergen Hoeller, Harry Yang
-
字段概要
从接口继承的字段 cn.taketoday.core.io.Resource
EMPTY_ARRAY -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明(专用程序包) booleancheckReadable(URL url) longThis method reads the entire InputStream to determine the content length.protected voidCustomize the givenHttpURLConnectionbefore fetching the resource.protected voidCustomize the givenURLConnectionbefore fetching the resource.booleanexists()This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened.getFile()This implementation returns a File reference for the underlying class path resource, provided that it refers to a file in the file system.protected FileThis implementation returns a File reference for the given URI-identified resource, provided that it refers to a file in the file system.protected FileThis implementation determines the underlying File (or jar file, in case of a resource in a jar/zip).booleanisFile()This implementation always returnsfalse.protected booleanDetermine whether the givenURIrepresents a file in a file system.booleanThis implementation always returnstruefor a resource thatexists(revised as of 5.1).longThis implementation checks the timestamp of the underlying File, if available.This implementation returns a FileChannel for the given URI-identified resource, provided that it refers to a file in the file system.从类继承的方法 cn.taketoday.core.io.AbstractResource
createRelative, equals, getName, getURI, getURL, hashCode, isDirectory, isOpen, list, list, toString从接口继承的方法 cn.taketoday.core.io.InputStreamSource
getInputStream, getReader, getReader从接口继承的方法 cn.taketoday.core.io.Resource
getContentAsByteArray, getContentAsString
-
构造器详细资料
-
AbstractFileResolvingResource
public AbstractFileResolvingResource()
-
-
方法详细资料
-
exists
public boolean exists()从类复制的说明:AbstractResourceThis implementation checks whether a File can be opened, falling back to whether an InputStream can be opened.This will cover both directories and content resources.
- 指定者:
exists在接口中Resource- 覆盖:
exists在类中AbstractResource
-
isReadable
public boolean isReadable()从类复制的说明:AbstractResourceThis implementation always returnstruefor a resource thatexists(revised as of 5.1).- 指定者:
isReadable在接口中Resource- 覆盖:
isReadable在类中AbstractResource- 另请参阅:
-
checkReadable
-
isFile
public boolean isFile()从类复制的说明:AbstractResourceThis implementation always returnsfalse.- 指定者:
isFile在接口中Resource- 覆盖:
isFile在类中AbstractResource- 另请参阅:
-
getFile
This implementation returns a File reference for the underlying class path resource, provided that it refers to a file in the file system.- 指定者:
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- 另请参阅:
-
getFileForLastModifiedCheck
This implementation determines the underlying File (or jar file, in case of a resource in a jar/zip).- 覆盖:
getFileForLastModifiedCheck在类中AbstractResource- 返回:
- the File to use for timestamp checking (never
null) - 抛出:
FileNotFoundException- if the resource cannot be resolved as an absolute file path, i.e. is not available in a file systemIOException- in case of general resolution/reading failures
-
isFile
Determine whether the givenURIrepresents a file in a file system.- 另请参阅:
-
getFile
This implementation returns a File reference for the given URI-identified resource, provided that it refers to a file in the file system. -
readableChannel
This implementation returns a FileChannel for the given URI-identified resource, provided that it refers to a file in the file system.- 返回:
- 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
从类复制的说明:AbstractResourceThis method reads the entire InputStream to determine the content length.For a custom subclass of
InputStreamResource, we strongly recommend overriding this method with a more optimal implementation, e.g. checking File length, or possibly simply returning -1 if the stream can only be read once.- 指定者:
contentLength在接口中Resource- 覆盖:
contentLength在类中AbstractResource- 抛出:
IOException- if the resource cannot be resolved (in the file system or as some other known physical resource type)- 另请参阅:
-
lastModified
从类复制的说明:AbstractResourceThis implementation checks the timestamp of the underlying File, if available.- 指定者:
lastModified在接口中Resource- 覆盖:
lastModified在类中AbstractResource- 抛出:
IOException- if the resource cannot be resolved (in the file system or as some other known physical resource type)- 另请参阅:
-
customizeConnection
Customize the givenURLConnectionbefore fetching the resource.Calls
ResourceUtils.useCachesIfNecessary(URLConnection)and delegates tocustomizeConnection(HttpURLConnection)if possible. Can be overridden in subclasses.- 覆盖:
customizeConnection在类中AbstractResource- 参数:
con- the URLConnection to customize- 抛出:
IOException- if thrown from URLConnection methods
-
customizeConnection
Customize the givenHttpURLConnectionbefore fetching the resource.Can be overridden in subclasses for configuring request headers and timeouts.
- 覆盖:
customizeConnection在类中AbstractResource- 参数:
con- the HttpURLConnection to customize- 抛出:
IOException- if thrown from HttpURLConnection methods
-