Java: An Introduction to Problem Solving and Programming (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
Question
Book Icon
Chapter 10, Problem 12PP
Program Plan Intro

HTTP URL connection

Program Plan:

Filename: Http_URL_Connection.java

  • Import the required header files.
  • Declare the class “Http_URL_Connection”.
    • Declare the main method.
      • Declare the variable and assign the URL to the variable.
      • Declare the variable and assign the user agent.
      • Create an object for URL.
      • Open the URL connection.
      • Set the request methods.
      • Get the response code.
      • Display the URL.
      • Display the response code.
      • If the “res” is equal to “HttpURLCinection.HTTP_OK”, read the file line by line and display it.
      • Finally close the stream.
      • Otherwise, display error message.

Blurred answer
Students have asked these similar questions
Write a program to Validate an IPv4 Address.       According to Wikipedia, IPv4 addresses are canonically represented in   dot-decimal notation, which consists of four decimal numbers,   each ranging from 0 to 255, separated by dots, e.g., 172.16.254.1 .           The generalized form of an IPv4 address is (0-255).(0-255).(0-255).(0-255).   Here we are considering numbers only from 0 to 255 and   any additional leading zeroes will be considered invalid.       Your task is to complete the function isValid which returns 1,   if the ip address is valid else returns 0.       The function takes a string s as its only argument .       **************************************************************************/       // SOLUTION (in C++):       #include <bits/stdc++.h>       using namespace std;       int isValid(string s)   {   s += '.';   int countDots = 0;   string str = "";   for (int i = 0; i < s.length(); i++)   {…
Write a JAVA program for HTML is the language of web pages. Items start and end with tags. A table starts with <table> and ends with </table>. In a table, a row starts with <tr> and ends with </tr>. In a row, a column starts with <td> and ends with </td>. Given two integers for rows and columns, generate an appropriately sized html table. Place the character c in each table cell. If the input is 2 3, the output is: <table> <tr> <td> c </td> <td> c </td> <td> c </td> </tr> <tr> <td> c </td> <td> c </td> <td> c </td> </tr> </table>
Done in Perl. Showing process would be nice. Write a program to accept in an HTML string. search through the string and use a regular expression to pick out all valid URLs. A URL is enclosed in quotes and should begin with "http://. Display a list of all the valid URLs

Chapter 10 Solutions

Java: An Introduction to Problem Solving and Programming (8th Edition)

Ch. 10.3 - Prob. 11STQCh. 10.4 - Write some Java code to create an output stream of...Ch. 10.4 - Give three statements that will write the values...Ch. 10.4 - Give a statement that will close the stream toFile...Ch. 10.4 - What import statement(s) do you use when creating...Ch. 10.4 - Prob. 16STQCh. 10.4 - Give three statements that will read three numbers...Ch. 10.4 - Give a statement that will close the stream...Ch. 10.4 - Can you use writeInt to write a number to a file...Ch. 10.4 - Can you use readUTF to read a string from a text...Ch. 10.4 - Prob. 21STQCh. 10.4 - Prob. 22STQCh. 10.4 - Does the class FileInputStream have a method named...Ch. 10.4 - Does the class FileOutputStream have a constructor...Ch. 10.4 - Does the class ObjectOutputStream have a...Ch. 10.4 - Prob. 26STQCh. 10.4 - Suppose that a binary file contains exactly three...Ch. 10.4 - The following code appears in the program in...Ch. 10.4 - Prob. 29STQCh. 10.5 - Prob. 30STQCh. 10.5 - Prob. 31STQCh. 10.5 - Prob. 32STQCh. 10.5 - Prob. 33STQCh. 10.6 - Prob. 34STQCh. 10.6 - Prob. 35STQCh. 10 - Write a program that will write the Gettysburg...Ch. 10 - Modify the program in the previous exercise so...Ch. 10 - Write some code that asks the user to enter either...Ch. 10 - Write a program that will record the purchases...Ch. 10 - Modify the class LapTimer, as described in...Ch. 10 - Write a class TelephoneNumber that will hold a...Ch. 10 - Write a class contactInfo to store contact...Ch. 10 - Write a program that reads every line in a text...Ch. 10 - Repeat the previous exercise, but write the new...Ch. 10 - Write a program that will make a copy of a text...Ch. 10 - Suppose you are given a text file that contains...Ch. 10 - Suppose that you have a binary file that contains...Ch. 10 - Suppose that we want to store digitized audio...Ch. 10 - Write a program RecoverSignal that will read the...Ch. 10 - Even though a binary file is not a text file, it...Ch. 10 - Write a program that searches a file of numbers...Ch. 10 - Write a program that reads a file of numbers of...Ch. 10 - The following is an old word puzzle: Name a common...Ch. 10 - The Social Security Administration maintains an...Ch. 10 - The following is a list of scores for a game....Ch. 10 - Write a program that checks a text file for...Ch. 10 - Prob. 5PPCh. 10 - Prob. 6PPCh. 10 - Revise the class Pet, as shown in Listing 6.1 of...Ch. 10 - Write a program that reads records of type Pet...Ch. 10 - Prob. 12PP
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,