Question: Using the mechanism described in Special Topic 11.1, write a program that reads all data from a web page and writes them to a file.
Using the mechanism described in Special Topic 11.1, write a program that reads all data from a web page and writes them to a file. Prompt the user for the web page URL and the file.
Data from special topic 11.1

Special Topic 11.1 Reading Web Pages You can read the contents of a web page with this sequence of commands: String address = "http://horstmann.com/index.html"; URL pageLocation = new URL (address); Scanner in = new Scanner (pageLocation. openStream () ); Now simply read the contents of the web page with the Scanner in the usual way. The URL constructor and the openStream method can throw an IOException, so you need to tag the main method with throws IOException. (See Section 11.4.3 for more information on the throws clause.) The URL class is contained in the java.net package. EXAMPLE CODE See special_topic_1 of your eText or companion code for a program that reads data from a web page.
Step by Step Solution
3.53 Rating (156 Votes )
There are 3 Steps involved in it
Based on the information given in Special Topic 111 Ill guide you through writing a Java program that reads all data from a web page URL provided by t... View full answer
Get step-by-step solutions from verified subject matter experts
