spring-framework / org.springframework.core.io / FileUrlResource

FileUrlResource

open class FileUrlResource : UrlResource, WritableResource

Subclass of UrlResource which assumes file resolution, to the degree of implementing the WritableResource interface for it.

This is the class resolved by DefaultResourceLoader for a "file:..." URL location, allowing a downcast to WritableResource for it.

Alternatively, for direct construction from a java.io.File handle, consider using FileSystemResource. For an NIO java.nio.file.Path, consider using PathResource instead.

Author
Juergen Hoeller

Since
5.0.2

Constructors

<init>

FileUrlResource(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,

FileUrlResource(location: String)

Create a new FileUrlResource based on the given file location, using the URL protocol "file".

The given parts will automatically get encoded if necessary.

Functions

createRelative

open fun createRelative(relativePath: String): Resource

getOutputStream

open fun getOutputStream(): OutputStream

isWritable

open fun isWritable(): Boolean

writableChannel

open fun writableChannel(): WritableByteChannel