Obtain the domain name of a website and the domain name of the website.
Question requirements
"Randomly enter a URL
"Takes out the Domain Name of the website and displays it
Program Implementation
1 package cn. fury. test; 2 3 import java. util. required; 4 5 public class Test {6 public static void main (String [] args) {7 blocks SC = new blocks (System. in); 8 System. out. println ("Please input a Uniform Resource Locator:"); 9 String URL = SC. nextLine (); 10 int start = URL. indexOf ('. '); 11 int end = URL. indexOf ('. ', start + 1); 12 String domain_name = URL. substring (start + 1, end); 13 System. out. println ("The domain name of the URL inputted by you is:" + domain_name); 14} 15}
View Code
Program upgrade
"Assumes that a batch of web sites are available
"Randomly select one of the URLs, find its domain name, and display
"Notice: This programmer is relatively lazy and keeps updating ......