• Object Storage Service

  1. Help Center
  2. Object Storage Service
  3. Developer Guide (Java SDK)
  4. Bucket Management
  5. Identifying Whether a Bucket Exists

Identifying Whether a Bucket Exists

You can call ObsClient.headBucket to identify whether a bucket exists. Sample code is as follows:

String endPoint = "yourdomainname";
String ak = "*** Provide your Access Key ***";
String sk = "*** Provide your Secret Key ***";
// Create an instance of ObsClient.
ObsClient obsClient = new ObsClient(ak, sk, endPoint);

boolean exists = obsClient.headBucket("bucketname");

// Close obsClient.