public abstract class ResourceUtils
extends java.lang.Object
Resources.Resource,
WritableResource| Constructor and Description |
|---|
ResourceUtils() |
| Modifier and Type | Method and Description |
|---|---|
static org.springframework.core.io.WritableResource |
asStrictlyWritableResource(org.springframework.core.io.Resource resource)
Returns the
Resource as a WritableResource if possible. |
static java.util.Optional<org.springframework.core.io.WritableResource> |
asWritableResource(org.springframework.core.io.Resource resource)
Optionally return the Resource as a WritableResource. |
static boolean |
isNotEmpty(byte[] array)
Determines whether the given byte array is null or empty.
|
static boolean |
isReadable(org.springframework.core.io.Resource resource)
Null-safe operation to determine whether the given
Resource is readable. |
static boolean |
isWritable(org.springframework.core.io.Resource resource)
Null-safe operation to determine whether the given
Resource is writable. |
static java.lang.String |
nullSafeGetDescription(org.springframework.core.io.Resource resource)
Null-safe method to get the
description of the given Resource. |
@NonNull
public static org.springframework.core.io.WritableResource asStrictlyWritableResource(@Nullable
org.springframework.core.io.Resource resource)
Resource as a WritableResource if possible.
This method makes a best effort to determine whether the target Resource is actually writable.
Even still, it may be possible that a write to the target Resource will fail.
The Resource is writable if the Resource is an instance of WritableResource
and WritableResource.isWritable() returns true.resource - Resource to cast to a WritableResource.WritableResource from the target Resource if possible; never null.java.lang.IllegalStateException - if the target Resource is not writable.WritableResource,
Resourcepublic static java.util.Optional<org.springframework.core.io.WritableResource> asWritableResource(@Nullable
org.springframework.core.io.Resource resource)
Optionally return the Resource as a WritableResource.
The Resource must be an instance of WritableResource.resource - Resource to cast to a WritableResource.Resource as a WritableResource if the Resource
is an instance of WritableResource, otherwise returns Optional.empty().WritableResource,
Resource,
Optionalpublic static boolean isNotEmpty(@Nullable
byte[] array)
array - byte array to evaluate.public static boolean isReadable(@Nullable
org.springframework.core.io.Resource resource)
Resource is readable.resource - Resource to evaluate.Resource is readable.Resource.isReadable(),
Resourcepublic static boolean isWritable(@Nullable
org.springframework.core.io.Resource resource)
Resource is writable.resource - Resource to evaluate.Resource is writable.WritableResource.isWritable(),
WritableResource,
Resource@Nullable
public static java.lang.String nullSafeGetDescription(@Nullable
org.springframework.core.io.Resource resource)
description of the given Resource.resource - Resource to describe.description of the Resource, or null
if the Resource handle is null.Resource