Using
try-with-resources on
AutoCloseables will not just improve readability of the code, but it will make your code more robust as well.
Catching disjoint exception types avoids code duplication, which makes your code easier to maintain.
I'm not a fan of switch statements in general. I prefer to map strings to objects that can perform different tasks through
polymorphism. For instance, instead of:
You can do:
Another cool language enhancement you can use with Java 7 is the diamond operator. When initializing a variable of a generic type, you don't have to repeat the generic type arguments in the constructor call: