使用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 != ⑴){
System.out.print((char)respInt);
respInt = insr.read();
}
本文来源:https://www.yuntue.com/post/59883.html | 云服务器网,转载请注明出处!