title: Amazon S3 - List all the zip files recursively within S3 bucket using Java API
body: <p>I've a S3 bucket on the Amazon and trying to get the list of all the zip files located within folders under the bucket recursively.</p>
  
  <p>For e.g, my zip files are located as shown below :</p>
  
  <pre><code>bucket1/${user1}/${date1}/abc.zip
  bucket1/${user2}/${date2}/xyz.zip
  bucket1/${user3}/${date3}/mno.zip
  
  bucketName=bucket1
  prefix=bucket1/
  </code></pre>
  
  <p>Below is my code : </p>
  
  <pre><code>final AmazonS3 amazonS3 = AmazonS3Utils.getAmazonS3Client();
  final ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName("bucket1")
                                                                              .withPrefix("bucket1/");
  
  ObjectListing current = amazonS3.listObjects(listObjectsRequest);
  final List&lt;S3ObjectSummary&gt; keyList = current.getObjectSummaries();
  
  while (current.isTruncated()) 
  {
     keyList.addAll(current.getObjectSummaries());
     current = amazonS3.listNextBatchOfObjects(current);
  }
  
  keyList.addAll(current.getObjectSummaries());
  for(S3ObjectSummary summary : keyList)
  {
      System.out.println(summary.getKey());
  }
  </code></pre>
  
  <p>But I get back an empty list.</p>
  
  <p>Am I doing anything wrong ? Is there any way to recursively get list of zip files from the bucket ?</p>