final Foo foo = new SomeFoo(); try (final AutoCloseable ignored = foo::close) { foo.doFoo(); } |
Autoclosable method reference trick in Java 8
Reply
final Foo foo = new SomeFoo(); try (final AutoCloseable ignored = foo::close) { foo.doFoo(); } |