Sep
16
|
// Create query string String queryString = "param1=" + URLEncoder.encode(param1Value, "UTF-8"); queryString += "¶m2=" + URLEncoder.encode(param2Value, "UTF-8"); // Make connection URL url = new URL("http://www.obiweb.com.au"+queryString); URLConnection urlConnection = url.openConnection(); // Read the response BufferedReader in = new BufferedReader( new InputStreamReader(urlConnection.getInputStream())); String line = null; while ((line = in.readLine()) != null) { System.out.println(line); } in.close();
Array ( ) 2 Responses to “How do I send a GET request using Java?”
Leave a Reply
You must be logged in to post a comment.
February 21st, 2012 at 6:34 pm
out.close(); should not be there – there is no “out” stream opened
February 21st, 2012 at 8:52 pm
Thanks, have updated the post