Java HTTP Get httpGetString(String url)

Here you can find the source of httpGetString(String url)

Description

http Get String

License

LGPL

Declaration

public static String httpGetString(String url) throws IOException 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.io.*;
import java.net.HttpURLConnection;

import java.net.URL;

public class Main {
    public static String httpGetString(String url) throws IOException {

        StringBuilder result = new StringBuilder();
        HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
        conn.setRequestMethod("GET");
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;/*  w  w w .  j  av  a2  s  .c o  m*/
        while ((line = rd.readLine()) != null) {
            result.append(line);
        }
        rd.close();
        return result.toString();

    }
}

Related

  1. httpGet(String url, boolean logStdout)
  2. httpGet(String url, StringBuffer response)
  3. httpGet(String urlStr)
  4. httpGet(String urlStr)
  5. httpGet(String urlToRead)
  6. readUrl(final String strUrl)
  7. readURL(final String textURL)
  8. readUrl(HttpURLConnection conn)
  9. readUrl(String url, String token)