toResource

通过提供的 ByteArray 直接构建一个 Resource

Return

Resource object representing the ByteArray data.

@JvmName(name = "valueOf")
fun File.toResource(charset: Charset = Charsets.UTF_8): FileResource

Converts a File to a FileResource.

Return

The converted FileResource.


@JvmName(name = "valueOf")
fun Path.toResource(charset: Charset = Charsets.UTF_8, vararg options: OpenOption): PathResource

Converts the given Path to a PathResource with the specified options.

Return

the PathResource representing the converted path

Parameters

options

the options to use for opening the resource (vararg)


@JvmName(name = "valueOf")
fun URL.toResource(charset: Charset = Charsets.UTF_8): URIResource

Converts the current URL to a URIResource.

使用 URL 构建的 URIResource 在使用 URIResource.stringURIResource.inputStream 时应当不会再产生 IllegalArgumentExceptionMalformedURLException 了,因为 URL 已经初始化好了。 取而代之的是 URL.toResource 可能会产生 URISyntaxException, 因为需要使用 URL.toURI

Return

The converted URIResource.

Throws


@JvmName(name = "valueOf")
fun URI.toResource(charset: Charset = Charsets.UTF_8): URIResource

Converts the current URI to a URIResource.

Return

The converted URIResource.