title: How to check if bucket already exists in AWS S3
body: <p>How can I check if the bucket already exists in my Aws S3 account using Java SDK?</p>
  <p>Using below code</p>
  <pre><code>        AmazonS3ClientBuilder.defaultClient().doesBucketExistV2(bucketName);
  </code></pre>
  <p>Checks global existence of bucket and returns true if a bucket with this name exists globally even if I am not the owner of this bucket or I don't have access to that bucket.</p>
  <p>I understand the intent for making this method this way so that It allows us to determine the availability of bucket name but this is not what I need.
  Of course, it will throw exception that I don't have access to it later, but it returns stating that bucket with this name exists.</p>
  <p>I want to check if the bucket with the given name <strong>exists in my S3 account</strong> so that I can perform operations on it.</p>
  <p>One possible solution for it can be to <code>list</code> all the buckets and search for my bucket in that returned list which I feel is not a good performance-wise (correct me if I am wrong) as there can be hundreds of thousands of buckets and searching in them is not efficient.</p>
  <p>How can I determine if a <em><strong>bucket exists in my S3 account not checking global existence</strong></em>?</p>