Class FileUrlResource
java.lang.Object
nl.basjes.parse.useragent.utils.springframework.core.io.AbstractResource
nl.basjes.parse.useragent.utils.springframework.core.io.AbstractFileResolvingResource
nl.basjes.parse.useragent.utils.springframework.core.io.UrlResource
nl.basjes.parse.useragent.utils.springframework.core.io.FileUrlResource
- All Implemented Interfaces:
InputStreamSource
,Resource
Subclass of {link UrlResource} which assumes file resolution, to the degree
of implementing the {link WritableResource} interface for it. This resource
variant also caches resolved {link File} handles from {link #getFile()}.
This is the class resolved by {link DefaultResourceLoader} for a "file:..." URL location, allowing a downcast to {link WritableResource} for it.
Alternatively, for direct construction from a {link java.io.File} handle or NIO {link java.nio.file.Path}, consider using {link FileSystemResource}.
- Since:
- 5.0.2
- Author:
- Juergen Hoeller
-
Constructor Summary
ConstructorDescriptionFileUrlResource
(URL url) Create a newFileUrlResource
based on the given URL object. -
Method Summary
Modifier and TypeMethodDescriptioncreateRelative
(String relativePath) This implementation creates aUrlResource
, delegating to {link #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.Methods inherited from class nl.basjes.parse.useragent.utils.springframework.core.io.UrlResource
createRelativeURL, equals, getDescription, getFilename, getInputStream, getURL, hashCode
Methods inherited from class nl.basjes.parse.useragent.utils.springframework.core.io.AbstractFileResolvingResource
contentLength, customizeConnection, customizeConnection, exists, getFile
Methods inherited from class nl.basjes.parse.useragent.utils.springframework.core.io.AbstractResource
toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface nl.basjes.parse.useragent.utils.springframework.core.io.InputStreamSource
getInputStream
Methods inherited from interface nl.basjes.parse.useragent.utils.springframework.core.io.Resource
contentLength, getDescription, getFilename, getURL
-
Constructor Details
-
FileUrlResource
Create a newFileUrlResource
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.
- Parameters:
url
- a URL see ResourceUtils#isFileURL(URL) see #getFile()
-
-
Method Details
-
getFile
Description copied from class:UrlResource
This implementation returns a File reference for the underlying URL/URI, provided that it refers to a file in the file system. see org.springframework.util.ResourceUtils#getFile(java.net.URL, String)- Specified by:
getFile
in interfaceResource
- Overrides:
getFile
in classUrlResource
- Throws:
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 see #getInputStream()
-
createRelative
Description copied from class:UrlResource
This implementation creates aUrlResource
, delegating to {link #createRelativeURL(String)} for adapting the relative path. see #createRelativeURL(String)- Specified by:
createRelative
in interfaceResource
- Overrides:
createRelative
in classUrlResource
- Parameters:
relativePath
- the relative path (relative to this resource)- Returns:
- the resource handle for the relative resource
- Throws:
MalformedURLException
-