Use IOUtils.copy instead of custom code