Java try-with-resources

try-with-resources is a powerful feature got introduced as part of Java SE 7 which simplifies resource management and helps prevent…