9.2. HTTP and Java

Java provides extremely good support for the HyperText Transfer Protocol. While developers are free to write their own HTTP implementations using TCP sockets, the java.net package provides several classes that offer HTTP functionality:

  • java.net.URL

  • java.net.URLConnection

  • java.net.HttpURLConnection

9.2.1. URL Class

The URL class represents one of the most frequently used address types of the Internet, the Uniform Resource Locator (URL). URLs can point to files, Web sites, ftp sites, newsgroups, e-mail addresses, and other resources. Some fictitious examples of non-Web URLs are:

  • ftp://records.area51.mil/roswell/subjects/autopsy/

  • telnet://localhost:8000/

  • mailto:president@whitehouse.gov?subject=My%20Opinion

In the context of HTTP and ...

Get Java™ Network Programming and Distributed Computing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.