Class Closer


  • public final class Closer
    extends java.lang.Object
    Helper class for closing resources.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void close​(java.lang.AutoCloseable closeable)
      Closes an AutoCloseable or ignores if null.
      static boolean closeSilently​(java.lang.AutoCloseable closeable)
      Closes an AutoCloseable and returns true if it closed without exception.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • close

        public static void close​(java.lang.AutoCloseable closeable)
                          throws java.lang.Exception
        Closes an AutoCloseable or ignores if null.
        Parameters:
        closeable - the resource to close; may be null
        Throws:
        java.lang.Exception - if the resource cannot be closed
        Since:
        2.8
      • closeSilently

        public static boolean closeSilently​(java.lang.AutoCloseable closeable)
        Closes an AutoCloseable and returns true if it closed without exception.
        Parameters:
        closeable - the resource to close; may be null
        Returns:
        true if resource was closed successfully, or false if an exception was thrown