Skip to content

Instantly share code, notes, and snippets.

@Ribesg
Created January 9, 2014 10:50
Show Gist options
  • Save Ribesg/8332391 to your computer and use it in GitHub Desktop.
Save Ribesg/8332391 to your computer and use it in GitHub Desktop.
// Java 6
SomeStream stream
try {
stream = new SomeStream(someArg);
// Stuff
} catch (SomeStreamExceptions e) {
// Stuff
} final {
try {
stream.close();
} catch (SomeFailedToCloseException ignored) {}
}
// Java 7
try (SomeStream stream = new SomeStream(someArg)) {
// Stuff
} catch (SomeStreamExceptions e) {
// Stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment