使用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();
}