Question: Code in Java Write a Java program to parse and get all the parts of a URL, like the examples below. If none, leave blank.

Code in Java

Write a Java program to parse and get all the parts of a URL, like the examples below. If none, leave blank. You can try it out by getting the URL from user input, or by just creating a String assigned to any URL of your choice to see if it provides similar results.

What is a URL? https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL URL Example: http://www.example.com:80/path/to/myfile.html?key1=value1&key2=value2#SomewhereInTheDocument Protocol: http Subdomain: www Domain name: example.com Port: 80 Path: /path/to File: myfile.html Parameters: ?key1=value1&key2=value2 Anchor: #SomewhereInTheDocument URL Example: https://www.youtube.com/watch?v=gBgyMyBnoXE

Protocol: https Subdomain: www Domain name: youtube.com Port: Path: /watch File: Parameters: ?v=gBgyMyBnoXE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!