public enum CloseableUtil extends Enum<CloseableUtil>
Closeable or AutoCloseable resources.
This class provides a method to close a resource without throwing any exceptions, logging them instead.
Since this class is defined as an enum without instances, it cannot be instantiated and is essentially a utility class.| Modifier and Type | Method and Description |
|---|---|
static void |
closeQuietly(AutoCloseable closeable)
Closes the provided
AutoCloseable resource quietly, without throwing any exceptions. |
static CloseableUtil |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static CloseableUtil[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static CloseableUtil[] values()
for (CloseableUtil c : CloseableUtil.values()) System.out.println(c);
public static CloseableUtil valueOf(String name)
name - the name of the enum constant to be returned.IllegalArgumentException - if this enum type has no constant with the specified nameNullPointerException - if the argument is nullpublic static void closeQuietly(AutoCloseable closeable)
AutoCloseable resource quietly, without throwing any exceptions.
If an exception does occur while closing the resource, it is logged as a warning and not propagated.closeable - the closeable resource to close, may be any object implementing AutoCloseableCopyright © 2024. All rights reserved.