Learning Java Programming Made Easy
Java Connection Class:
The Java URLConnection class represents a communication link between the URL and the application. This class can be used to read and write data to the specified resource referred by the URL.
The openConnection() method of URL class returns the object of URLConnection class. Syntax:
public URLConnection openConnection()throws IOException{}
Example:
Java Connection Class:
The Java URLConnection class represents a communication link between the URL and the application. This class can be used to read and write data to the specified resource referred by the URL.
The openConnection() method of URL class returns the object of URLConnection class. Syntax:
public URLConnection openConnection()throws IOException{}
Example:
- import java.io.*;
- import java.net.*;
- public class URLConnectionExample {
- public static void main(String[] args){
- try{
- URL url=new URL("http://www.javatpoint.com/java-tutorial");
- URLConnection urlcon=url.openConnection();
- InputStream stream=urlcon.getInputStream();
- int i;
- while((i=stream.read())!=-1){
- System.out.print((char)i);
- }
- }catch(Exception e){System.out.println(e);}
- }
- }
Տince the adrmin of this web site is ᴡorking, no uncertainty very ѕhortly it will bbe renowned, due to its feature contents.
ReplyDelete