Dump a page using the HTTPS protocol : HttpsURLConnection « Network Protocol « Java






Dump a page using the HTTPS protocol

 

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

public class Main {
  public static void main(String[] argv) throws Exception {

    URL url = new URL("https://www.server.com");
    HttpURLConnection con = (HttpURLConnection) url.openConnection();

    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine;

    while ((inputLine = in.readLine()) != null)
      System.out.println(inputLine);
    in.close();
  }
}

   
  








Related examples in the same category

1.Certification for HTTPS
2.Read data from a URL
3.Accessing a Password-Protected URL
4.Disabling Certificate Validation in an HTTPS Connection