amazon web services – AWS S3, list objects with multiple prefix using aws java sdk

I am using aws java sdk 2 to get a list of objects from S3.
Here I am able to list all the objects with prefix 102/

            ListObjectsRequest listObjects = ListObjectsRequest
                    .builder()
                    .bucket(BUCKET_NAME)
                    .prefix("102/")
                    .build();

But, I want to list objects with multiple prefixes (~20). How can I achieve that in a single request.

I tried the below, But this is only listing the objects with prefix 104/

            ListObjectsRequest listObjects = ListObjectsRequest
                    .builder()
                    .bucket(BUCKET_NAME)
                    .prefix("102/")
                    .prefix("103/")
                    .prefix("104/")
                    .build();

How can I achieve this listing with multiple prefixes in a single call. Any help is much appreciated.

Read more here: Source link