CSCI 202 homework 4

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.

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: /csci202
Next 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