//snippet-sourcedescription:[StreamTranscriptionBehaviorImpl.java demonstrates how to   .]
// snippet-service:[transcribe]
// snippet-keyword:[Java]
// snippet-sourcesyntax:[java]
// snippet-keyword:[Amazon Transcribe]
// snippet-keyword:[Code Sample]
// snippet-keyword:[TranscribeStreamingAsyncClient]
// snippet-keyword:[StartStreamTranscriptionResponse]
// snippet-sourcetype:[snippet]
// snippet-sourcedate:[2019-01-10]
// snippet-sourceauthor:[AWS]
// snippet-start:[transcribe.java-streaming-client-behavior-imp]

/**
 * Implementation of StreamTranscriptionBehavior to define how a stream response is handled.
 *
 * COPYRIGHT:
 *
 * Copyright 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.
 * A copy of the License is located at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * or in the "license" file accompanying this file. 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.amazonaws.transcribestreaming;

import com.amazonaws.transcribestreaming.StreamTranscriptionBehavior;
import software.amazon.awssdk.services.transcribestreaming.model.Result;
import software.amazon.awssdk.services.transcribestreaming.model.StartStreamTranscriptionResponse;
import software.amazon.awssdk.services.transcribestreaming.model.TranscriptEvent;
import software.amazon.awssdk.services.transcribestreaming.model.TranscriptResultStream;

import java.util.List;

public class StreamTranscriptionBehaviorImpl implements StreamTranscriptionBehavior {


    @Override
    public void onError(Throwable e) {
        System.out.println("=== Failure encountered ===");
        e.printStackTrace();
    }

    @Override
    public void onStream(TranscriptResultStream e) {
        // EventResultStream has other fields related to the timestamp of the transcripts in it.
        // Please refer to the javadoc of TranscriptResultStream for more details
        List<Result> results = ((TranscriptEvent) e).transcript().results();
        if (results.size() > 0) {
            if (results.get(0).alternatives().size() > 0)
                if (!results.get(0).alternatives().get(0).transcript().isEmpty()) {
                    System.out.println(results.get(0).alternatives().get(0).transcript());
                }
        }
    }

    @Override
    public void onResponse(StartStreamTranscriptionResponse r) {

        System.out.println(String.format("=== Received initial response. Request Id: %s ===", r.requestId()));
    }

    @Override
    public void onComplete() {
        System.out.println("=== All records streamed successfully ===");
    }
}
// snippet-end:[transcribe.java-streaming-client-behavior-imp]
@@ -79,18 +79,53 @@
  how to 
-  
+implement StreamTranscriptionBehavior
 .%5D%0D%0A// s
@@ -571,125 +571,8 @@
 **%0D%0A
- * Implementation of StreamTranscriptionBehavior to define how a stream response is handled.%0D%0A *%0D%0A * COPYRIGHT:%0D%0A *%0D%0A
  * C
@@ -645,17 +645,30 @@
 %0A *%0D%0A * 
-L
+This file is l
 icensed 
@@ -790,20 +790,16 @@
 License.
-%0D%0A *
  A copy 
@@ -800,16 +800,20 @@
  copy of
+%0D%0A *
  the Lic
@@ -842,20 +842,16 @@
 %0D%0A *
-    
  http://
 www.
@@ -850,51 +850,41 @@
 p://
-www.apache.org/licenses/LICENSE-
+aws.amazon.com/apache
 2.0
+/
 %0D%0A *%0D%0A *
  or 
@@ -883,57 +883,8 @@
 %0D%0A *
- or in the %22license%22 file accompanying this file.
  Thi
@@ -904,20 +904,16 @@
 tributed
-%0D%0A *
  on an %22
@@ -947,16 +947,20 @@
 NTIES OR
+%0D%0A *
  CONDITI
@@ -982,20 +982,16 @@
 , either
-%0D%0A *
  express
@@ -1026,16 +1026,20 @@
  for the
+%0D%0A *
  specifi
@@ -1058,20 +1058,16 @@
 overning
-%0D%0A *
  permiss
@@ -1107,16 +1107,20 @@
 cense.%0D%0A
+ *%0D%0A
  */%0D%0Apac
@@ -1166,79 +1166,8 @@
 %0D%0A%0D%0A
-import com.amazonaws.transcribestreaming.StreamTranscriptionBehavior;%0D%0A
 impo
@@ -1509,18 +1509,16 @@
 tream;%0D%0A
-%0D%0A
 import j
@@ -2795,28 +2795,30 @@
 reaming-client-behavior-imp%5D
+%0D%0A

Update StreamTranscriptionBehaviorImpl.java