Linux 拨号vps windows公众号手机端

java中如何访问https

lewis 6年前 (2019-04-11) 阅读数 15 #程序编程
文章标签 HTTPSJava

使用java访问https,具体方法如下:

URL reqURL = new URL("https://www.baidu.com" ); //创建URL对象

HttpsURLConnection httpsConn = (HttpsURLConnection)reqURL.openConnection();

//取得该连接的输入流,以读取响应内容

InputStreamReader insr = new InputStreamReader(httpsConn.getInputStream();

//读取服务器的响应内容并显示

int respInt = insr.read();

while( respInt != -1){

 System.out.print((char)respInt);

 respInt = insr.read();

}

版权声明

本文仅代表作者观点,不代表米安网络立场。

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

热门