类 FileUrlResource

    • 字段详细资料

      • file

        private volatile java.io.File file
    • 构造器详细资料

      • FileUrlResource

        public FileUrlResource​(java.net.URL url)
        Create a new FileUrlResource based 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
        另请参阅:
        ResourceUtils.isFileUrl(URL), getFile()
      • FileUrlResource

        public FileUrlResource​(java.lang.String location)
                        throws java.net.MalformedURLException
        Create a new FileUrlResource based 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)
        抛出:
        java.net.MalformedURLException - if the given URL specification is not valid
        另请参阅:
        UrlResource(String, String), ResourceUtils.URL_PROTOCOL_FILE
    • 方法详细资料

      • getFile

        public java.io.File getFile()
                             throws java.io.IOException
        从类复制的说明: UrlResource
        This 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
        抛出:
        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)
      • writableChannel

        public java.nio.channels.WritableByteChannel writableChannel()
                                                              throws java.io.IOException
        从接口复制的说明: WritableResource
        Return a WritableByteChannel.

        It is expected that each call creates a fresh channel.

        The default implementation returns Channels.newChannel(OutputStream) with the result of WritableResource.getOutputStream().

        指定者:
        writableChannel 在接口中 WritableResource
        返回:
        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
        另请参阅:
        WritableResource.getOutputStream()