code: public void downloadS3Object(S3ObjectSummary s3ObjectSummary,
        String targetDirectory)
        throws IOException {
  
      final AmazonS3 amazonS3 = getS3Client();
  
      final GetObjectRequest getObjectRequest = new GetObjectRequest(
          s3ObjectSummary.getBucketName(),
          s3ObjectSummary.getKey());
  
      final S3Object s3Object = amazonS3.getObject(getObjectRequest);
  
      final String targetFile = StringUtils.removeEnd(targetDirectory, File.separator) + File.separator + s3Object.getKey();
      FileUtils.copyInputStreamToFile(s3Object.getObjectContent(), new File(targetFile));
  
      LOGGER.info("S3 object downloaded to file: " + targetFile);
    }
docs: *
  Download a S3 object to local directory
  
  @param s3ObjectSummary S3 object summary for the object to download
  @param targetDirectory Local target directory to download the object to
  @throws IOException If any errors were encountered in downloading the object