Rules of submission
This assignment must be submitted to the Moodle submission page for Homework 4 by 11:00 PM on Friday, 15 February.
In addition to the task described below, your submission must conform to the following rules.
- There must be a
Home04class within theedu.unca.cs.csci202package. -
All of your Java program files must contain an
@authorfield with your full name and email address, not just your userid. Your email address should be inside angle brackets (< >). -
You may submit either a single Home04.java
file or a property packaged .tar.gz
or .zip archive that contains a
single Home04.java file.
Scripts will be used to find your
Home04class. -
Your
Home04must contain amainmethod that accomplishes the task.
The task
Write a program that reads a
URI,
for example http://www.cs.unca.edu/csci202,
contained on the first input line.
Your program should use a constructor for
Java’s URI class to create a URI object.
If an exception is raised by the constructor, your program should print a message giving some information about that problem.
If no exception is raised, your program should print the
scheme, host and path of the URI using
the appropriate methods of the URI. You really don’t
need to know what a scheme is. Just call the appropriate method.
If any of these URI properties is missing, it should not be printed.
Examples
In this case http://www.cs.unca.edu/csci202 was the input.
Scheme: http Host: www.cs.unca.edu Path: /csci202Next the input is
homework/home04.html was the input.
Notice that there is no scheme or host.
Path: homework/home04.html
Finally Not a real URI is the input.
Exception java.net.URISyntaxException: Illegal character in path at index 3: Not a real URI