Online Java Compiler By
JavaTpoint.com
import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; public class JavaHttpURLConnectionGetRequestMethodExample1 { //Starting the main method... public static void main(String h[]) throws IOException { //starting the try block try { String link_url = "https://www.javatpoint.com"; URL obj1 = new URL(link_url); //URL Connection Created... HttpURLConnection con1 = (HttpURLConnection) obj1.openConnection(); //Http URL Connection Created... System.out.println("https://www.javatpoint.com"); System.out.println("Connection Response Message : "+con1.getResponseMessage()); con1.disconnect(); } catch (Exception e) { System.out.println( e); } } }
Output