- Distributed Computing in Java 9
- Raja Malleswara Rao Pattamsetti
- 279字
- 2021-07-02 21:02:32
URLs, URLConnections, and the ContentHandler classes
While surfing the internet, we use URLs extensively. As a result, many of us perceive URL as the names of files located on the WWW, but that is not true; a URL could also point to other resources on a network, such as a database query or command output and so on.
A URL can be defined as an acronym for Uniform Resource Locator and is a reference (an address) to a resource on the internet.
Every URL has two main components: a protocol identifier and resource name. Suppose we have http://www.google.com; in this case, HTTP is the protocol identifier and www.google.com is the resource name. They are joined together with a colon (:) followed by two slashes (//), as shown in the following screenshot:

Protocols could be of many types, such as HTTP, HTTPS, file, gopher, FTP, and news. Here, the resource name represents the full address of the resource and contains the hostname, filename, port number, and reference. In many URLs, you might have seen that the hostname is mandatory, whereas the filename, port number, and reference are optional.
URL can be constructed in Java using the following syntax; note that URL addresses are passed in the form of a string to the URL class constructor:
URL urlHandle = new URL("http://example.com/");
The URL shown in the preceding code is the absolute URL where all the details are given. In addition to this, URLs could be relative to some already existing URL, as shown in the following example:
URL urlHandle = new URL("http://example.com/pages/");
URL firstPage = new URL(urlHandle, "page1.html");
- 編寫高質量代碼:改善Python程序的91個建議
- Python圖形化編程(微課版)
- Mastering Apache Storm
- ASP.NET求職寶典
- Arduino機器人系統設計及開發
- INSTANT Apache ServiceMix How-to
- Spark技術內幕:深入解析Spark內核架構設計與實現原理
- 陪孩子像搭積木一樣學編程:Python真好玩+Scratch趣味編程(全2冊)
- SFML Essentials
- 軟件測試
- 小小的Python編程故事
- Head First Go語言程序設計
- C++ Primer(中文版)(第5版)
- RPA開發:UiPath入門與實戰
- Java核心技術·卷Ⅱ:高級特性(原書第10版)