Sunday, 24 April 2016

How to send a HTTP GET request ?


Send a HTTP GET request

Example
String requestUrl = "http: //www.google.be";
try {
    URL url = new URL(requestUrl);
    BufferedReader in = 
        new BufferedReader(new InputStreamReader(url.openStream()));

    String inputLine;
    System.out.println("-----RESPONSE START-----");
    while ((inputLine = in.readLine()) != null) {
        System.out.println(inputLine);
    }

    in.close();
    System.out.println("-----RESPONSE END-----");
 } catch (IOException e) {
    e.printStackTrace();

 }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.