Do the Java platform libraries support https
All I need to to do is to connect via https. Must I u开发者_StackOverflowse commons client for this?
No, you don't have to, you can use a regular URLConnection
. Something like this:
public class URLConnectionReader {
public static void main(String[] args) throws Exception {
URL url = new URL("https://jax-ws.dev.java.net/");
URLConnection uc = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
uc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
}
in.close();
}
}
This may require a bit more work if the site you're connecting to uses a certificate that has not been signed by a well known CA or a self-signed certificate. But this is another story.
Yes. Just use the URL class and specify an HTTPS url.
精彩评论