---
title: "List Objects in a Bucket"
url: https://docs.catalyst.zoho.com/en/sdk/java/v1/cloud-scale/stratus/list-objects/
description: "This page lists the Java SDK method to get the objects stroed in a bucket."
last_updated: 2026-09-08T11:07:33Z
service: Cloud Scale
type: general
related_links:
- name: "Stratus Component Help Documentation"
url: /en/cloud-scale/help/stratus/introduction
- name: "JavaScript SDK Documentation"
url: /en/sdk/javascript/v1/cloudscale/stratus/check-object/
- name: "Python SDK"
url: /en/sdk/python/v1/cloud-scale/stratus/list-objects/
- name: "iOS SDK"
url: /en/sdk/ios/v2/cloud-scale/stratus/get-object/
- name: "Android SDK"
url: /en/sdk/android/v2/cloud-scale/stratus/get-object/
- name: "Flutter SDK"
url: /en/sdk/flutter/v2/cloud-scale/stratus/get-object/
- name: "REST API"
url: /en/api/code-reference/cloud-scale/stratus/get-all-buckets/#GetAllBuckets
---
# List Objects in a Bucket
### List All Objects by Pagination
This SDK method will allow you to get all the objects present in a particular bucket by pagination. The Bucket reference used in the below code snippet is the [component instance](https://docs.catalyst.zoho.com/en/sdk/java/v1/cloud-scale/stratus/create-bucket-instance/).
> **Info:** To use this SDK method, you need intialize it with **Admin** scope. You can learn more about this requirement from this [section](https://docs.catalyst.zoho.com/en/sdk/nodejs/v2/overview/#initialize-sdk-with-scopes)
For each call, a limited number of objects will be returned, and the next call will be initiated only if a continuation token is returned.
**Parameters Used**
| Parameter Name |
Data Type |
Definition |
| `maxKey` |
**String** |
A **Mandatory** parameter. Will contain the maximum limit of objects that can be listed by pagination. |
| `nextToken` |
**String** |
An **Mandatory** parameter. Will contain the token to get the next set of objects. |
| `prefix` |
**String** |
An **Optional** parameter. To list objects that match the prefix value. |
| `orderBy` |
**String** |
An **Optional** parameter. To list objects either in ascending or descending order. **Default Value**: `asc` |
The response we get will contain the following properties of the bucket, which will be stored in `moreOptions`:
* `key count`: Will contain the value of the number of objects that are being returned
* `max keys`: The maximum limit of objects that can be returned
* `Truncated`: Will contain the status to notify if a bucket is truncated or not.
* `contents`: List of object details
* `continuation_token`: If you a sent a `continuation_token` in the request, it will be shown in the response.
* `next_continuation_token`: If the response was truncated, the value of this key must be passed as `continuation_token` to the same method for retrieving the next set of objects.
With each iteration, we will list the `maxKey` number of objects and check if `nextToken` has been created. Using `nextToken` we will continue the iteration till all the objects have been listed.
**Ensure the following packages are imported:**
```java
import com.zc.component.stratus.ZCBucket;
import com.zc.component.stratus.ZCStratus;
import com.zc.component.stratus.beans.ZCListObjectOptions;
import com.zc.component.stratus.beans.ZCPagedObjectResponse;
import com.zc.component.stratus.ZCObject;
```
```java
String nextToken = null;
String maxKey = "10";
String prefix = "Sam";
do {
ZCListObjectOptions options = new ZCListObjectOptions();
options.setMaxKey(maxKey); // Default: 1000
options.setContinuationToken(nextToken); // Fetch next page
options.setFolderListing("true"); // Default: false
options.setOrderBy("desc"); // Default: "asc"
options.setPrefix(prefix); // Optional
ZCPagedObjectResponse res = bucket.listPagedObjects(options);
System.out.println("Object count: " + res.getKeyCount());
System.out.println("Max key: " + res.getMaxKey());
System.out.println("Is truncated: " + res.getTruncated());
for (ZCObject key : res.getContents()) {
System.out.println("Object name: " + key.getKey());
System.out.println("Content type: " + key.getContentType());
System.out.println("Size: " + key.getSize());
System.out.println("Metadata: " + key.getMetaData());
System.out.println("Version ID: " + key.getVersionId());
System.out.println("ETag: " + key.getEtag());
System.out.println("Object type: " + key.getKeyType());
System.out.println("Cached URL: " + key.getCachedUrl());
}
nextToken = res.getNextToken();
} while (nextToken != null);
```
### List Objects Through Iteration
Using this SDK method, you can get all the objects present in a bucket in a single API call, using iteration technique. The Bucket reference used in the below code snippet is the [component instance](https://docs.catalyst.zoho.com/en/sdk/java/v1/cloud-scale/stratus/create-bucket-instance/).
> **Info:** To use this SDK method, you need intialize it with **Admin** scope. You can learn more about this requirement from this [section](https://docs.catalyst.zoho.com/en/sdk/nodejs/v2/overview/#initialize-sdk-with-scopes)
**Ensure the following packages are imported:**
```java
import java.util.Iterator;
import com.zc.component.stratus.ZCObject;
import com.zc.component.stratus.beans.ZCListObjectOptions;
import java.util.List;
```
```java
ZCListObjectOptions options = new ZCListObjectOptions();
options.setFolderListing("true"); // Default: false
options.setMaxKey("2"); // Default: 1000
options.setOrderBy("desc"); // Default: "asc"
// Get iterable object list
Iterable<List<ZCObject>> paginationIterable = bucket.listIterableObjects(options);
Iterator<List<ZCObject>> iterator = paginationIterable.iterator();
while (iterator.hasNext()) {
List<lZCObject> objectList = iterator.next();
for (ZCObject obj : objectList) {
System.out.println(obj.getKey());
}
}
```