类 AbstractFileResolvingResource

  • 所有已实现的接口:
    InputStreamSource, Resource
    直接已知子类:
    ClassPathResource, UrlResource

    public abstract class AbstractFileResolvingResource
    extends AbstractResource
    Copy from https://github.com/spring-projects/spring-framework.git, with less modifications 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.

    从以下版本开始:
    3.0
    作者:
    Juergen Hoeller
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      (专用程序包) boolean checkReadable​(java.net.URL url)  
      long contentLength()
      This method reads the entire InputStream to determine the content length.
      protected void customizeConnection​(java.net.HttpURLConnection con)
      Customize the given HttpURLConnection, obtained in the course of an exists(), contentLength() or lastModified() call.
      protected void customizeConnection​(java.net.URLConnection con)
      Customize the given URLConnection, obtained in the course of an exists(), contentLength() or lastModified() call.
      boolean exists()
      This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened.
      java.io.File 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 java.io.File getFile​(java.net.URI uri)
      This implementation returns a File reference for the given URI-identified resource, provided that it refers to a file in the file system.
      protected java.io.File getFileForLastModifiedCheck()
      This implementation determines the underlying File (or jar file, in case of a resource in a jar/zip).
      boolean isFile()
      This implementation always returns false.
      protected boolean isFile​(java.net.URI uri)
      This implementation returns a File reference for the given URI-identified resource, provided that it refers to a file in the file system.
      boolean isReadable()
      This implementation always returns true for a resource that exists (revised as of 5.1).
      long lastModified()
      This implementation checks the timestamp of the underlying File, if available.
      java.nio.channels.ReadableByteChannel readableChannel()
      This implementation returns a FileChannel for the given URI-identified resource, provided that it refers to a file in the file system.
      • 从类继承的方法 java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • 构造器详细资料

      • AbstractFileResolvingResource

        public AbstractFileResolvingResource()
    • 方法详细资料

      • exists

        public boolean exists()
        从类复制的说明: AbstractResource
        This 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
      • checkReadable

        boolean checkReadable​(java.net.URL url)
      • isFile

        protected boolean isFile​(java.net.URI uri)
        This implementation returns a File reference for the given URI-identified resource, provided that it refers to a file in the file system.
        从以下版本开始:
        5.0
        另请参阅:
        getFile(URI)
      • getFile

        public java.io.File getFile()
                             throws java.io.IOException
        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
        抛出:
        java.io.FileNotFoundException - if the resource cannot be resolved as absolute file path, i.e. if the resource is not available in a file system
        java.io.IOException - in case of general resolution/reading failures
        另请参阅:
        ResourceUtils.getFile(URL, String)
      • getFile

        protected java.io.File getFile​(java.net.URI uri)
                                throws java.io.IOException
        This implementation returns a File reference for the given URI-identified resource, provided that it refers to a file in the file system.
        抛出:
        java.io.IOException
        另请参阅:
        ResourceUtils.getFile(URI, String)
      • getFileForLastModifiedCheck

        protected java.io.File getFileForLastModifiedCheck()
                                                    throws java.io.IOException
        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)
        抛出:
        java.io.FileNotFoundException - if the resource cannot be resolved as an absolute file path, i.e. is not available in a file system
        java.io.IOException - in case of general resolution/reading failures
      • readableChannel

        public java.nio.channels.ReadableByteChannel readableChannel()
                                                              throws java.io.IOException
        This implementation returns a FileChannel for the given URI-identified resource, provided that it refers to a file in the file system.
        指定者:
        readableChannel 在接口中 Resource
        覆盖:
        readableChannel 在类中 AbstractResource
        返回:
        the byte channel for the underlying resource (must not be null)
        抛出:
        java.io.FileNotFoundException - if the underlying resource doesn't exist
        java.io.IOException - if the content channel could not be opened
        从以下版本开始:
        5.0
        另请参阅:
        getFile()
      • contentLength

        public long contentLength()
                           throws java.io.IOException
        从类复制的说明: AbstractResource
        This method reads the entire InputStream to determine the content length. For a custom sub-class 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
        抛出:
        java.io.IOException - if the resource cannot be resolved (in the file system or as some other known physical resource type)
        另请参阅:
        InputStreamSource.getInputStream()
      • customizeConnection

        protected void customizeConnection​(java.net.HttpURLConnection con)
                                    throws java.io.IOException
        Customize the given HttpURLConnection, obtained in the course of an exists(), contentLength() or lastModified() call. Sets request method "HEAD" by default. Can be overridden in subclasses.
        参数:
        con - the HttpURLConnection to customize
        抛出:
        java.io.IOException - if thrown from HttpURLConnection methods