//snippet-sourcedescription:[S3AsyncStreamOps.java demonstrates how to use the streaming operations of an S3 asynchronous client.]
//snippet-keyword:[SDK for Java 2.0]
//snippet-keyword:[Code Sample]
//snippet-service:[s3]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[soo-aws]
/*
 * Copyright 2011-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *    http://aws.amazon.com/apache2.0
 *
 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
 * OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and
 * limitations under the License.
 */
package com.example.s3;
// snippet-start:[s3.java2.async_stream_ops.complete]
// snippet-start:[s3.java2.async_stream_ops.import]

import software.amazon.awssdk.core.async.AsyncResponseTransformer;
import software.amazon.awssdk.services.s3.S3AsyncClient;
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
import software.amazon.awssdk.utils.FunctionalUtils;

import java.nio.file.Paths;
import java.util.concurrent.CompletableFuture;
// snippet-end:[s3.java2.async_stream_ops.import]
// snippet-start:[s3.java2.async_stream_ops.main]
public class S3AsyncStreamOps {

    private static final String BUCKET = "sample-bucket";
	private static final String KEY = "testfile.out";

	public static void main(String[] args) {
    	S3AsyncClient client = S3AsyncClient.create();
      final CompletableFuture<GetObjectResponse> futureGet = client.getObject(
                GetObjectRequest.builder()
                                .bucket(BUCKET)
                                .key(KEY)
                                .build(),
                AsyncResponseTransformer.toFile(Paths.get("myfile.out")));
      futureGet.whenComplete((resp, err) -> {
            try {
                if (resp != null) {
                    System.out.println(resp);
                } else {
                    // Handle error
                    err.printStackTrace();
                }
            } finally {
                // Lets the application shut down. Only close the client when you are completely done with it
                client.close();
            }
        });

      futureGet.join();
    }
}
 
// snippet-end:[s3.java2.async_stream_ops.main]
// snippet-end:[s3.java2.async_stream_ops.complete]

@@ -121,17 +121,16 @@
 s client
-.
 %5D%0D%0A//sni
@@ -278,16 +278,26 @@
 cedate:%5B
+2020-02-06
 %5D%0D%0A//sni
@@ -325,16 +325,18 @@
 o-aws%5D%0D%0A
+%0D%0A
 /*%0D%0A * C
@@ -355,10 +355,10 @@
 1-20
-19
+20
  Ama
@@ -964,16 +964,18 @@
 plete%5D%0D%0A
+%0D%0A
 // snipp
@@ -1019,18 +1019,16 @@
 mport%5D%0D%0A
-%0D%0A
 import s
@@ -1284,64 +1284,8 @@
 e;%0D%0A
-import software.amazon.awssdk.utils.FunctionalUtils;%0D%0A%0D%0A
 impo
@@ -1408,16 +1408,18 @@
 mport%5D%0D%0A
+%0D%0A
 // snipp
@@ -1500,31 +1500,31 @@
 %0D%0A%0D%0A    
-private
+ public
  static 
 final St
@@ -1519,150 +1519,734 @@
 tic 
-final String BUCKET = %22sample-bucket%22;%0D%0A%09private static final String KEY = %22testfile.out%22;%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A
+void main(String%5B%5D args) %7B%0D%0A%0D%0A        final String USAGE = %22%5Cn%22 +%0D%0A                %22Usage:%5Cn%22 +%0D%0A                %22    S3AsyncOps %3Cbucketname%3E %3Cobjectname%3E %3Cpath%3E%5Cn%5Cn%22 +%0D%0A                %22Where:%5Cn%22 +%0D%0A                %22    bucketname - the name of the bucket (i.e., bucket1)%5Cn%5Cn%22 +%0D%0A                %22    objectname - the name pf the object object (i.e., book.pdf)%5Cn%22 +%0D%0A                %22    path - the local path to the file (i.e., C:%5C%5CAWS%5C%5Cbook.pdf)%5Cn%22 +%0D%0A                %22Example:%5Cn%22 +%0D%0A                %22    bucket1 book.pdf  C:%5C%5CAWS%5C%5Cbook.pdf%5Cn%22;%0D%0A%0D%0A         // snippet-start:%5Bs3.java2.copy_object.main%5D%0D%0A         String bucketName = args%5B0%5D;%0D%0A         String objectKey = args%5B1%5D;%0D%0A         String path = args%5B2%5D;%0D%0A%0D%0A 
     
-%09
+   
 S3As
@@ -2285,24 +2285,26 @@
 .create();%0D%0A
+  
       final 
@@ -2443,41 +2443,29 @@
     
-        .bucket(BUCKET)%0D%0A        
+.bucket(bucketName)%0D%0A
     
@@ -2493,22 +2493,20 @@
 key(
-KEY)%0D%0A        
+objectKey)%0D%0A
     
@@ -2598,26 +2598,20 @@
 get(
-%22myfile.out%22
+path
 )));%0D%0A
+  
     
@@ -3083,24 +3083,26 @@
 );%0D%0A%0D%0A      
+  
 futureGet.jo
@@ -3118,17 +3118,16 @@
   %7D%0D%0A%7D%0D%0A
- 
 %0D%0A// sni

Update S3AsyncStreamOps.java