There are more than 8 ways you could send request to any URL using HTTP GET or HTTP POST call in Java.
With the latest Java APIs and every release had new improved way to make URL calls.
Life of developer definitely improved a lot over last few years with frequent release of Java JDK.
In this tutorial we will go over How to send HTTP Request and Capture complete Response (Payload) in Java using url.openStream() API.
package com.crunchify.tutorials; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; /** * @author Crunchify.com */ public class CrunchifyFetchURLData { public static void main(String[] args) { try { URL url = new URL("https://crunchify.com/"); BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream())); String strTemp = ""; while (null != (strTemp = br.readLine())) { System.out.println(strTemp); } } catch (Exception ex) { ex.printStackTrace(); } } }
You may want to take a look at these Java Tutorials, Eclipse Tutorials, WordPress Tutorials.