类 Closeables


  • public class Closeables
    extends java.lang.Object
    Utils for deal with Closeables and AutoCloseables
    • 构造器概要

      构造器 
      构造器 说明
      Closeables()  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static void closeAll​(@NonNull java.lang.Throwable throwable, @NonNull java.util.List<@Nullable java.lang.AutoCloseable> closeables)
      Close all resources.
      static void closeAll​(@NonNull java.lang.Throwable throwable, @Nullable java.lang.AutoCloseable @NonNull ... closeables)
      Close all resources.
      static void closeQuietly​(@Nullable java.lang.AutoCloseable closeable)
      Close the closeable, if exception occurred, silently swallow it.
      static void closeQuietly​(@Nullable java.lang.AutoCloseable @NonNull ... closeables)
      Close the closeable, if exception occurred, silently swallow it.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 构造器详细资料

      • Closeables

        public Closeables()
    • 方法详细资料

      • 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 exception
        closeables - 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 exception
        closeables - the resources to close