@@ -0,0 +1,2947 @@
+// snippet-comment:%5BThese are tags for the AWS doc team's sample catalog. Do not remove.%5D%0A// snippet-sourcedescription:%5BCreateBucketAsync.java demonstrates how to create an Amazon Simple Storage Service (Amazon S3) object using the Async client.%5D%0A//snippet-keyword:%5BAWS SDK for Java v2%5D%0A//snippet-keyword:%5BCode Sample%5D%0A//snippet-service:%5BAmazon S3%5D%0A//snippet-sourcetype:%5Bfull-example%5D%0A//snippet-sourcedate:%5B10/06/2021%5D%0A//snippet-sourceauthor:%5Bscmacdon-aws%5D%0A%0A/*%0A   Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.%0A   SPDX-License-Identifier: Apache-2.0%0A*/%0A%0Apackage com.example.s3.async;%0A%0Aimport software.amazon.awssdk.regions.Region;%0Aimport software.amazon.awssdk.services.s3.S3AsyncClient;%0Aimport software.amazon.awssdk.services.s3.model.*;%0Aimport java.net.URISyntaxException;%0Aimport java.util.concurrent.CompletableFuture;%0A%0A/**%0A * To run this AWS code example, ensure that you have setup your development environment, including your AWS credentials.%0A *%0A * For information, see this documentation topic:%0A *%0A * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html%0A */%0Apublic class CreateBucketAsync %7B%0A%0A    public static void main(String%5B%5D args) throws URISyntaxException %7B%0A        final String USAGE = %22%5Cn%22 +%0A                %22Usage:%5Cn%22 +%0A                %22    %3CbucketName%3E %5Cn%5Cn%22 +%0A                %22Where:%5Cn%22 +%0A                %22    bucketName - the name of the bucket to create. The bucket name must be unique, or an error occurs.%5Cn%5Cn%22 ;%0A%0A        if (args.length != 1) %7B%0A            System.out.println(USAGE);%0A            System.exit(1);%0A        %7D%0A%0A        String bucketName = args%5B0%5D;%0A        System.out.format(%22Creating a bucket named %25s%5Cn%22,%0A                bucketName);%0A%0A        Region region = Region.US_EAST_1;%0A        S3AsyncClient s3AsyncClient  = S3AsyncClient.builder()%0A                .region(region)%0A                .build();%0A%0A        createBucket (s3AsyncClient, bucketName);%0A    %7D%0A%0A    public static void createBucket( S3AsyncClient s3AsyncClient, String bucketName) %7B%0A        try %7B%0A%0A            CreateBucketRequest bucketRequest = CreateBucketRequest.builder()%0A                    .bucket(bucketName)%0A                    .build();%0A%0A            CompletableFuture%3CCreateBucketResponse%3E futureGet  = s3AsyncClient.createBucket(bucketRequest);%0A            futureGet.whenComplete((resp, err) -%3E %7B%0A                try %7B%0A                    if (resp != null) %7B%0A                        System.out.println(bucketName +%22 is ready~%22);%0A                    %7D else %7B%0A                        err.printStackTrace();%0A                    %7D%0A                %7D finally %7B%0A                    // Only close the client when you are completely done with it.%0A                    s3AsyncClient.close();%0A                %7D%0A            %7D);%0A            futureGet.join();%0A%0A        %7D catch (S3Exception e) %7B%0A            System.err.println(e.awsErrorDetails().errorMessage());%0A            System.exit(1);%0A        %7D%0A    %7D%0A%7D%0A%0A

Create CreateBucketAsync.java