code: public static <T, U extends Closeable> T withCloseable(U self, @ClosureParams(value=FirstParam.class) Closure<T> action) throws IOException {
          try {
              T result = action.call(self);
  
              Closeable temp = self;
              self = null;
              temp.close();
  
              return result;
          } finally {
              DefaultGroovyMethodsSupport.closeWithWarning(self);
          }
      }
docs: Allows this closeable to be used within the closure, ensuring that it
  is closed once the closure has been executed and before this method returns.
  
  @param self the Closeable
  @param action the closure taking the Closeable as parameter
  @return the value returned by the closure
  @throws IOException if an IOException occurs.
  @since 2.4.0