16.3. Complete Examples

Several complete and working code examples accompany this reading so that readers can see the java.net.http package in some real-world situations. To download these examples, use the following command:

$ curl -s -L https://github.com/cs1302uga/cs1302-tutorials/raw/master/web/setup.sh | bash

Here is a list of the examples:

Name

Description

cs1302.web/cs1302.web.Example0

Get text content hosted by the Project Gutenberg website.

cs1302.web/cs1302.web.Example1

Get image data to construct a JavaFX Image object.

cs1302.web/cs1302.web.Example2

Get license data using the GitHub API, then parse the JSON-formatted string in the response body using Google’s Gson library.

cs1302.web/cs1302.web.Example3

Get results from the iTunes Search API, then parse the JSON-formatted string in the response body using Google’s Gson library.

To run an example, use the provided compile.sh script along with the name of the example:

$ ./compile.sh cs1302.web/cs1302.web.Example0