s3 how to iterate through the objects in buckets code example
Example: python loop over s3 objects]
AmazonS3Client s3 = new AmazonS3Client(myCredentials);
for ( S3ObjectSummary summary : S3Objects.withPrefix(s3, "my-bucket", "photos/") ) {
System.out.printf("Object with key '%s'n", summary.getKey());
}