Use IOUtils.copy with a counting stream wrapper