- AWS Code Sample demonstrates how to list Amazon Forecast datasets.

/* Copyright, Inc. or its affiliates. All Rights Reserved. This file is 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 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.forecast; import; import; import; import; import; import; import java.util.Iterator; import java.util.List; public class ListDataSets { public static void main(String[] args) { // Create a Forecast client Region region = Region.US_WEST_2; ForecastClient forecast = ForecastClient.builder() .region(region) .build(); listForecastDataSets(forecast); } public static void listForecastDataSets(ForecastClient forecast) { try { ListDatasetsRequest group = ListDatasetsRequest.builder() .maxResults(10) .build(); ListDatasetsResponse response = forecast.listDatasets(group); List<DatasetSummary> groups = response.datasets(); Iterator<DatasetSummary> groupsIterator = groups.iterator(); while(groupsIterator.hasNext()) { DatasetSummary myGroup =; System.out.println("The dataset name is " +myGroup.datasetName()) ; } } catch (ForecastException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }

Sample Details

Service: Amazon Forecast

Last tested: 5/4/2020

Author: scmacdon-aws

Type: full-example