Java URL Connection getHttpGetContent(String strUrl, String charSet)

Here you can find the source of getHttpGetContent(String strUrl, String charSet)

Description

get Http Get Content

License

Open Source License

Declaration

public static String getHttpGetContent(String strUrl, String charSet) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

public class Main {
    public static String getHttpGetContent(String strUrl) throws Exception {
        return getHttpGetContent(strUrl, "UTF-8");
    }//  ww  w. ja  va2s. c o m

    public static String getHttpGetContent(String strUrl, String charSet) throws Exception {
        URL url = new URL(strUrl);
        URLConnection conn = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), charSet));
        StringBuffer sb = new StringBuffer();
        String inputLine;
        while ((inputLine = in.readLine()) != null) {
            sb.append(inputLine).append(System.lineSeparator());
        }
        return sb.toString();
    }
}

Related

  1. getGlobalAddress(String url)
  2. getGlobalIPAddress(URL automationPage)
  3. getHeaderFieldLong(URLConnection conn, String name, long Default)
  4. getHTML(String url, boolean removeNonLatinChars)
  5. getHTML(URL url)
  6. getHttpHeaders(URLConnection connection)
  7. getHttpResponseHeader(URLConnection http)
  8. getImageFromURL(String remoteURL)
  9. getJar(String jarUrl)