title: Should Closeable be used as the Java equivalent for .NET's IDisposable?
body: <p><strong>Update</strong>: As @PaulGroke points out below, things have changed with Java 7: there now is <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html" rel="noreferrer">AutoCloseable</a>. Which isn't tied to streams and supported by the new <a href="http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html" rel="noreferrer">try-with-resources</a> construct.</p>
  <p><code>AutoCloseable</code> is the direct Java equivalent for .NET's <code>IDisposable</code> interface.</p>
  <hr />
  <p>The <code>Closeable</code> interface introduced in Java 1.5 is tightly tied to streams, and even has an exception specifier for <code>IOException</code>. This suggests that it should only be used for streams or other IO related activities, rather than general purpose cleanup logic.</p>
  <p>Certainly the description for the <code>close()</code> method would make absolutely no sense outside of a stream/IO context:</p>
  <blockquote>
  <p><code>void close() throws IOException</code></p>
  <p><em>Closes this stream and releases any system resources associated with it.</em></p>
  </blockquote>
  <p>Should I therefore declare my own interface, <code>Disposable</code>, with a <code>Dispose()</code> method on it, and use that as an analogue to .NET's <code>IDisposable</code> interface? Or should I re-use <code>Closeable</code> even though it may not be a perfect fit?</p>