Alternatively you can use minio-java . Its Open Source and compatible with AWS S3 API.
Using the ListBuckets API, you can easily implement it.
try {
// List buckets that have read access.
List bucketList = minioClient.listBuckets ();
for (Bucket bucket: bucketList) {
System.out.println (bucket.creationDate () + "," + bucket.name ());
}
} catch (MinioException e) {
System.out.println ("Error occured:" + e);
}
Hope this helps.
Disclaimer: I work for Minio
source share