Use a switch with enum, not if/else if
minor clean up
Use Charset.forName in order to get unchecked UnsupportedCharsetException
Clean up Charset handling