java.net.URI is a class in the java.net package that represents a Uniform Resource Identifier (URI). It provides several methods to manipulate and analyze different components of a URI. One of these methods is getHost(), which returns the host component of the URI.
Example 1:
Suppose we have a URI for a web page:
URI uri = new URI("https://www.example.com/about");
To get the host component of this URI, we can call the getHost() method:
String host = uri.getHost();
This will return the string "www.example.com".
Example 2:
Suppose we have a URI for an FTP server:
URI uri = new URI("ftp://ftp.example.com/files");
To get the host component of this URI, we can use the getHost() method:
String host = uri.getHost();
This will return the string "ftp.example.com".
Package Library: java.net
Java URI.getHost - 30 examples found. These are the top rated real world Java examples of java.net.URI.getHost extracted from open source projects. You can rate examples to help us improve the quality of examples.