类 Closeables
- java.lang.Object
-
- net.dongliu.commons.io.Closeables
-
public class Closeables extends java.lang.ObjectUtils for deal with Closeables and AutoCloseables
-
-
构造器概要
构造器 构造器 说明 Closeables()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static voidcloseAll(@NonNull java.lang.Throwable throwable, @NonNull java.util.List<@Nullable java.lang.AutoCloseable> closeables)Close all resources.static voidcloseAll(@NonNull java.lang.Throwable throwable, @Nullable java.lang.AutoCloseable @NonNull ... closeables)Close all resources.static voidcloseQuietly(@Nullable java.lang.AutoCloseable closeable)Close the closeable, if exception occurred, silently swallow it.static voidcloseQuietly(@Nullable java.lang.AutoCloseable @NonNull ... closeables)Close the closeable, if exception occurred, silently swallow it.
-
-
-
方法详细资料
-
closeQuietly
public static void closeQuietly(@Nullable java.lang.AutoCloseable closeable)
Close the closeable, if exception occurred, silently swallow it.- 参数:
closeable- the instance to be close. can be null
-
closeQuietly
public static void closeQuietly(@Nullable java.lang.AutoCloseable @NonNull ... closeables)
Close the closeable, if exception occurred, silently swallow it.- 参数:
closeables- the instances to be close.
-
closeAll
public static void closeAll(@NonNull java.lang.Throwable throwable, @Nullable java.lang.AutoCloseable @NonNull ... closeables)Close all resources. If exception is throw when close resource, it is added to Suppressed exception list of passed in Throwable. This behave just as try-with resource management. This method would not rethrow the passed in throwable, callers should rethrow it if needed.- 参数:
throwable- the origin exceptioncloseables- the resources to close
-
closeAll
public static void closeAll(@NonNull java.lang.Throwable throwable, @NonNull java.util.List<@Nullable java.lang.AutoCloseable> closeables)Close all resources. If exception is throw when close resource, it is added to Suppressed exception list of passed in Throwable. This behave just as try-with resource management. This method would not rethrow the passed in throwable, callers should rethrow it if needed.- 参数:
throwable- the origin exceptioncloseables- the resources to close
-
-