title: Helper to call close() if implements AutoCloseable?
body: <p>Is there any helper method in the JDK or common libraries that does this:</p>
  
  <pre><code>if (resource instanceof AutoCloseable) {
      ((AutoCloseable) resource).close();
  }
  </code></pre>
  
  <p>Just a one-liner to call an object's <code>close()</code> if applicable.</p>
  
  <p>I know about try-with-resources, that's not applicable to this situation.  And I know that not all classes that have a <code>close()</code> method implement <code>AutoCloseable</code>.  But, I seem to write the above over and over..</p>