Skip to content

Instantly share code, notes, and snippets.

@raags
Last active January 23, 2018 06:22
Show Gist options
  • Save raags/8c905137eca73ec3a33d to your computer and use it in GitHub Desktop.
Save raags/8c905137eca73ec3a33d to your computer and use it in GitHub Desktop.
Simple Java https client for testing
package JavaHttps;
import java.net.URL;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import javax.net.ssl.HttpsURLConnection;
import java.util.Scanner;
public class JavaHttpsExample
{
public static void main(String[] args)
throws Exception
{
// String httpsURL = "https://your.https.url.here/";
Scanner input = new Scanner(System.in);
System.out.println("Enter HTTPS Url: ");
String httpsURL = input.nextLine();
URL myurl = new URL(httpsURL);
HttpsURLConnection con = (HttpsURLConnection)myurl.openConnection();
InputStream ins = con.getInputStream();
InputStreamReader isr = new InputStreamReader(ins);
BufferedReader in = new BufferedReader(isr);
String inputLine;
while ((inputLine = in.readLine()) != null)
{
System.out.println(inputLine);
}
in.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment