you can just use IOUtils here too it accepts null etc. and ignores the IOException if you do closeWhileCatchi...