Last active
January 23, 2018 06:22
-
-
Save raags/8c905137eca73ec3a33d to your computer and use it in GitHub Desktop.
Simple Java https client for testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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