Class Closer

  • All Implemented Interfaces:

    public final class Closer
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Helper that holds onto AutoCloseable resources and releases them when its #close method is called.

    Similar to but can deal with AutoCloseable, and doesn't throw IOException.

    • Field Summary

      Modifier and Type Field Description
      private java.util.List<java.lang.AutoCloseable> list  
    • Constructor Summary

      Constructor Description
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <E extends java.lang.AutoCloseable>
      add​(E e)
      Registers a resource.
      void close()  
      • Methods inherited from class java.lang.Object

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

      • list

        private final java.util.List<java.lang.AutoCloseable> list
    • Constructor Detail

      • Closer

        public Closer()
    • Method Detail

      • add

        public <E extends java.lang.AutoCloseable> E add​(E e)
        Registers a resource.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable