Basic computer course, C programming language, Education, Engineering Course, Engineering Courses, Maths Coaching, online computer coaching, PGDCA course coaching, programming course, school computer coaching, training, Uncategorized, Web Design course

What is URLConnection class in Java? tccicomputercoaching.com

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 URLConnection class contains many methods that let you communicate with the URL over the network. URLConnection is a HTTP-centric class; that is, many of its methods are useful only when you are working with HTTP URLs.

java urlconnection

However, most URL protocols allow you to read from and write to the connection.

For run the programme related URL Connection you should know some built-in methods like,

  • URLConnection openConnection(): opens the connection to the specified URL.
  • OutputStream getOutputStream(): returns the output stream to this connection.
  • InputStream getInputStream(): returns the input stream to this open connection.

Steps involved in the above process:

1. URL Creation: Create a URL object using any of the constructors given int

2. this article

3. Create Object: Invoke the openConnection() call to create the object of URLConnection.

4. Display the Content: Either use the above created object to display the information about the resource or to read/write contents of the file to console using bufferedReader and InputStream of the open connection using getInputStream() method.

5. Close Stream: Close the InputStream when done.

To learn more in detail about URLConnection class, Java Netwroking , Advance Java at TCCI Coaching in Ahmedabad.

Online Coaching is available.

Call us @ 9825618292

Visit us @ http://tccicomputercoaching.com/java-language-course/

 

Leave a comment