@@ -0,0 +1,2636 @@
+//snippet-sourcedescription:%5BListDataSets.java demonstrates how to list Amazon Forecast data sets.%5D%0A//snippet-keyword:%5BSDK for Java 2.0%5D%0A//snippet-keyword:%5BCode Sample%5D%0A//snippet-service:%5BAmazon Forecast%5D%0A//snippet-sourcetype:%5Bfull-example%5D%0A//snippet-sourcedate:%5B5/4/2020%5D%0A//snippet-sourceauthor:%5Bscmacdon-aws%5D%0A%0A/*%0A   Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.%0A   This file is licensed under the Apache License, Version 2.0 (the %22License%22).%0A   You may not use this file except in compliance with the License. A copy of%0A   the License is located at%0A    http://aws.amazon.com/apache2.0/%0A   This file is distributed on an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR%0A   CONDITIONS OF ANY KIND, either express or implied. See the License for the%0A   specific language governing permissions and limitations under the License.%0A*/%0A%0Apackage com.example.forecast;%0A// snippet-start:%5Bforecast.java2.list_datasets.import%5D%0Aimport software.amazon.awssdk.regions.Region;%0Aimport software.amazon.awssdk.services.forecast.ForecastClient;%0Aimport software.amazon.awssdk.services.forecast.model.DatasetSummary;%0Aimport software.amazon.awssdk.services.forecast.model.ListDatasetsRequest;%0Aimport software.amazon.awssdk.services.forecast.model.ListDatasetsResponse;%0Aimport software.amazon.awssdk.services.forecast.model.ForecastException;%0Aimport java.util.Iterator;%0Aimport java.util.List;%0A// snippet-end:%5Bforecast.java2.list_datasets.import%5D%0A%0Apublic class ListDataSets %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        // Create a Forecast client%0A        Region region = Region.US_WEST_2;%0A        ForecastClient forecast = ForecastClient.builder()%0A                .region(region)%0A                .build();%0A%0A        listForecastDataSets(forecast);%0A    %7D%0A%0A    // snippet-start:%5Bforecast.java2.list_datasets.import%5D%0A    public static void listForecastDataSets(ForecastClient forecast) %7B%0A%0A       try %7B%0A           ListDatasetsRequest group = ListDatasetsRequest.builder()%0A                .maxResults(10)%0A                .build();%0A%0A           ListDatasetsResponse response = forecast.listDatasets(group);%0A           List%3CDatasetSummary%3E groups = response.datasets();%0A           Iterator%3CDatasetSummary%3E groupsIterator = groups.iterator();%0A%0A           while(groupsIterator.hasNext()) %7B%0A%0A            DatasetSummary myGroup = groupsIterator.next();%0A            System.out.println(%22The Data Set name is %22 +myGroup.datasetName()) ;%0A        %7D%0A       %7D catch (ForecastException e) %7B%0A           System.err.println(e.awsErrorDetails().errorMessage());%0A           System.exit(1);%0A       %7D%0A      // snippet-end:%5Bforecast.java2.list_datasets.import%5D%0A    %7D%0A%7D%0A

Create ListDataSets.java