Problem

Consider the following code:/*************************************************************...

Consider the following code:

/************************************************************** WebPageReader.java* Dean&Dean** This reads a web page through a buffer.*************************************************************/import java.util.Scanner;public class WebPageReader{   BufferedReader reader;   public WebPageReader(String webAddress)   {     URL url = new URL(webAddress);     URLConnection connection = url.openConnection();     InputStream in = connection.getInputStream();     reader = new BufferedReader(new InputStreamReader(in));   } // end constructor   //********************************************************   public String readLine()   {     return reader.readLine();   } // end readLine   //**********************************************************   public static void main(String[] args)   {      Scanner stdIn = new Scanner(System.in);      String url, line;      System.out.print("Enter a full URL address: ");      url = stdIn.nextLine();      WebPageReader wpr = new WebPageReader(url);      while ((line = wpr.readLine()) != null)      {        System.out.println(line);      }   } // end main} // end WebPageReader

Use this program as a starting point and make these adjustments to it:

• Add

import
statements as required.

• For each method call and constructor call:

If it throws an unchecked exception, ignore it.

If it throws a checked exception:

Specify the specific exception in a

throws
clause.

Within a generic catch block in

main,
catch any exception and print its class and message using
getClass
and
getMessage
method calls.

Be aware that your program might be correct, but it might not be able to access web pages successfully. To access web pages, your computer needs to have Internet access capabilities. If your firewall asks if it’s OK for Java to access the Internet, click “yes” and continue.

Here are three sample sessions:

First sample session:

Enter a full URL address: htp://www.park.edu

class java.net.MalformedURLException

unknown protocol: htp

Second sample session:

Enter a full URL address: http:/www.park.edu

class java.lang.IllegalArgumentException

protocol = http host = null

Third sample session:

Enter a full URL address: http://www.park.edu

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 16
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT