Java examples for Network:Http
do Https Get
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import javax.net.ssl.HttpsURLConnection; public class Main { public static void main(String[] argv) throws Exception { String url = "java2s.com"; System.out.println(doHttpsGet(url)); }//w w w.j a va 2 s. com public static String doHttpsGet(String url) throws MalformedURLException, IOException { // establish connection and send request HttpsURLConnection connection = (HttpsURLConnection) new URL(url) .openConnection(); connection.setRequestMethod("GET"); connection.setDoOutput(false); connection.setDoInput(true); // read response BufferedReader reader = new BufferedReader(new InputStreamReader( connection.getInputStream())); String line, content = ""; while ((line = reader.readLine()) != null) { content = content + line; } return content; } }