In this section, you will learn about the url connection reader. Here, first of all we are going to define class named "URLConnectionReader".
URL Connection Reader
In this section, you will learn about the url connection reader. Here, first of all we are going to define class named "URLConnectionReader". After that we make a URL object passing a url "http://www.javajazzup.com" as string in its constructor.
openConnection():
This is the method that returns a URLConnection object that represents a connection to the remote object referred to by the URL. A new connection is opened every time by calling the
openConnection() method of the protocol handler for this URL.
InputStreamReader(): An InputStreamReader is a bridge from byte stream to character stream, It reads bytes and decodes them into character using a specified charset.
BufferedReader: This constructor reads text from a character-input stream, buffering characters
so as to provide for the efficient reading of characters. A BufferedReader creates
a buffering character-input stream that uses a default sized input buffer.
Here is the code of this program.
import java.net.*;
|
Here is the Output of above program:
C:\rose>java URLConnectionReader URLConnection:http://www.javajazzup.com/ Enter the text: This is simple program. You entered String is: This is simple program. C:\rose> |