Java URL example: Getting text from URL – Send HTTP request GET/POST in Java

Crunchify Call URL Example

How to send HTTP request GET/POST in Java? How to use java.net.URLConnection to fire and handle HTTP? Below is a simple example to get Response from URL in Java Program.

The URLConnection class contains many methods that let you communicate with the URL over the network. URLConnection is an HTTP-centric class; that is, many of its methods are useful only when you are working with HTTP URLs. However, most URL protocols allow you to read from and write to the connection. urlconnection getinputstream usage.

This section describes both functions.

Have anything to add to this article? Please chime in and join the conversion.

Enjoyed this post?

Be sure to subscribe to the Crunchify newsletter and get regular updates about awesome posts just like this one and more! Join more than 13000 subscribers!

  • Dimitris

    Hello, I am running this code on Android aplication but I am falling to the exception. It seems like I cannot get the info. I cant see what the error is. Could you please help me somehow?

  • Bob

    Great !!!!!

    Working much better as the basic:
    readline()…..

    Thanks !!!

    • http://crunchify.com/ App Shah

      I’m glad it worked for you Bob :)

  • Raj

    Thanx

  • Gleb

    Where to get this theme?