We first fetch the entire S3 bucket list, then we iterate over the objects of the bucket, and if it contains the folder, then we iterate over the objects of the folder.
The complete code for listing is as follows:
package com.chapter3; import com.amazonaws.services.s3.model.Bucket; import com.amazonaws.services.s3.model.ListObjectsRequest; import com.amazonaws.services.s3.model.ObjectListing; import com.amazonaws.services.s3.model.S3ObjectSummary; public class ListFullHierarchy extends AmazonS3ClientInitializer{ public ListFullHierarchy() { super(); } public static void main(String[] args) { new CreateBucket().createBucket("sg-bucket-2015"); new CreateBucketWithLogging().createBucketWithLogging("sg-bucket-2015-with-logging"); new CreateBucketWithVersioning().createBucketWithVersioning("sg-bucket-2015-with-versioning"); new CreateFolderInBucket().createFolderInBucket("sg-bucket-2015", "sg-folder"); new UploadFileInBucket...