HttpsUrlReader.java - Reading Data from HTTPS URL

Q

How to read data from an HTTPS URL with jsse.jar? I want to see a Java program example.

✍: FYIcenter

A

jsse.jar, Java Secure Socket Extension, allows you to communicate securely with an SSL-enabled web server by using the "https" URL protocol.

Here is an example program, HttpsUrlReader.java, that can be used to read data from an HTTPS URL with jsse.jar:

// Copyright (c) FYIcenter.com
import java.net.*;
import java.io.*;

public class HttpsUrlReader {
   public static void main(String[] args) throws Exception {
      URL url = new URL("https://www.oracle.com/");
      BufferedReader in = new BufferedReader(
         new InputStreamReader(url.openStream()));
   
      String line;
      while ((line = in.readLine()) != null)
         System.out.println(line);
      in.close();
   }
}

You can compile and run the above example in a command window:

\fyicenter>\local\jdk-1.8.0\bin\javac HttpsUrlReader.java

\fyicenter>\local\jdk-1.8.0\bin\java HttpsUrlReader
   > oracle.html

Notes that:

  • There is no need to specify jsse.jar in the -cp option, since it is already included in the JDK package.
  • The output file oracle.html contains data securely received from the https://www.oracle.com website.

 

-Djavax.net.debug - jsse.jar Debugging Options

Examples for jsse.jar - Java Secure Socket Extension

Examples for jsse.jar - Java Secure Socket Extension

⇑⇑ FAQ for jsse.jar - Java Secure Socket Extension

2018-03-24, 2181🔥, 0💬