Get host string from a URI in Java
Description
The following code shows how to get host string from a URI.
Example
import java.net.URI;
//from w w w .jav a 2s . com
public class Main {
public static void main(String args[]) throws Exception {
URI u = new URI("http://www.java2s.com");
System.out.println("The host is " + u.getHost());
}
}
The code above generates the following result.