On his blog, Brian Oxley shows a neat way in JDK 8 to use non AutoCloseable object having a close-like method in a try with resources construct, using the new method references. For those of us who are still stuck with JDK 7 for some time, here is the (uglier) equivalent code:
final Foo foo = new Foo();try (AutoCloseable ignore = new AutoCloseable() {
@Overridepublicvoid close() {
foo.close();
}
}) {
foo.doFoo();
}