Sonar issue: Possible null pointer dereference
Sonar issue: Method may fail to clean up stream or resource on checked
exception
fix Eclipse warnings, close resource, remove redundant else