Answers for "send HTTP get request JAVA"

1

java http request

// open a connection, the request method is "GET" by default
URL url = new URL("http://example.com");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();

connection.setRequestMethod("GET");
connection.setRequestProperty("Content-Type", "application/json");

// you can use one of these methods to get the results
connection.connect();
connection.getResponseCode();
connection.getInputStream();
connection.getOutputStream();

// close the connection
connection.disconnect();
Posted by: Guest on April-22-2021
0

java send request

URL url = new URL("http://example.com");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
Posted by: Guest on October-10-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language