Obtain the domain name of a website and the domain name of the website.

Source: Internet
Author: User

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 ......

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.