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
ConstructorsConstructorDescriptionFileUrlResource(URL url) Create a newFileUrlResourcebased 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, getURI, getURL, hashCode, isFileMethods inherited from class nl.basjes.parse.useragent.utils.springframework.core.io.AbstractFileResolvingResource
contentLength, customizeConnection, customizeConnection, exists, getFile, isFileMethods inherited from class nl.basjes.parse.useragent.utils.springframework.core.io.AbstractResource
isOpen, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface nl.basjes.parse.useragent.utils.springframework.core.io.InputStreamSource
getInputStreamMethods inherited from interface nl.basjes.parse.useragent.utils.springframework.core.io.Resource
contentLength, exists, getDescription, getFilename, getURI, getURL, isFile, isOpen
-
Constructor Details
-
FileUrlResource
Create a newFileUrlResourcebased 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:UrlResourceThis 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:
getFilein interfaceResource- Overrides:
getFilein classUrlResource- Throws:
IOException- in case of general resolution/reading failures see #getInputStream()
-
createRelative
Description copied from class:UrlResourceThis implementation creates aUrlResource, delegating to {link #createRelativeURL(String)} for adapting the relative path. see #createRelativeURL(String)- Specified by:
createRelativein interfaceResource- Overrides:
createRelativein classUrlResource- Parameters:
relativePath- the relative path (relative to this resource)- Returns:
- the resource handle for the relative resource
- Throws:
MalformedURLException
-