- 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");
- Mastering Python Scripting for System Administrators
- UI智能化與前端智能化:工程技術、實現方法與編程思想
- MySQL數據庫管理與開發(慕課版)
- SQL Server 2016數據庫應用與開發習題解答與上機指導
- Linux Device Drivers Development
- 軟件供應鏈安全:源代碼缺陷實例剖析
- Oracle GoldenGate 12c Implementer's Guide
- 區塊鏈項目開發指南
- 現代C:概念剖析和編程實踐
- Arduino電子設計實戰指南:零基礎篇
- Python程序設計教程
- 數字媒體技術概論
- iOS Development with Xamarin Cookbook
- Visual C#(學習筆記)
- Game Programming using Qt 5 Beginner's Guide