ListForecasts搭配使用 AWS SDK - Amazon Forecast

Amazon Forecast 不再向新买家开放。Amazon Forecast 的现有客户可以继续照常使用该服务。了解更多

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

ListForecasts搭配使用 AWS SDK

以下代码示例显示了如何使用ListForecasts

Java
SDK适用于 Java 2.x
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库中进行设置和运行。

import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.forecast.ForecastClient; import software.amazon.awssdk.services.forecast.model.ListForecastsResponse; import software.amazon.awssdk.services.forecast.model.ListForecastsRequest; import software.amazon.awssdk.services.forecast.model.ForecastSummary; import software.amazon.awssdk.services.forecast.model.ForecastException; import java.util.List; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class ListForecasts { public static void main(String[] args) { Region region = Region.US_WEST_2; ForecastClient forecast = ForecastClient.builder() .region(region) .build(); listAllForeCasts(forecast); forecast.close(); } public static void listAllForeCasts(ForecastClient forecast) { try { ListForecastsRequest request = ListForecastsRequest.builder() .maxResults(10) .build(); ListForecastsResponse response = forecast.listForecasts(request); List<ForecastSummary> forecasts = response.forecasts(); for (ForecastSummary forecastSummary : forecasts) { System.out.println("The name of the forecast is " + forecastSummary.forecastName()); } } catch (ForecastException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }
  • 有关API详细信息,请参阅 “AWS SDK for Java 2.x API参考 ListForecasts” 中的。

有关 AWS SDK开发者指南和代码示例的完整列表,请参阅将 Forecast 与 S AWS DK 配合使用。本主题还包括有关入门的信息以及有关先前SDK版本的详细信息。