What exactly would you like to automatically close? Try with resources only works with Closeable instances.