请教一个问题
使用HttpsURLConnection这个类可以直接访问https的网站,也不需要证书
private void testIt1(){
URL url;
try {
url = new URL("https://www.alipay.com/index.html");
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
//dump all the content
if(con!=null){
System.out.println("****** Content of the URL ********");
BufferedReader br =new BufferedReader(new InputStreamReader(con.getInputStream()));
String input;
while ((input = br.readLine()) != null){
System.out.println(input);
}
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
换成httpclient怎么写
例如:我打开支付宝,在浏览器里输入网址即可,换成httpclient怎么写??
谢谢!
使用HttpsURLConnection这个类可以直接访问https的网站,也不需要证书
private void testIt1(){
URL url;
try {
url = new URL("https://www.alipay.com/index.html");
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
//dump all the content
if(con!=null){
System.out.println("****** Content of the URL ********");
BufferedReader br =new BufferedReader(new InputStreamReader(con.getInputStream()));
String input;
while ((input = br.readLine()) != null){
System.out.println(input);
}
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
换成httpclient怎么写
例如:我打开支付宝,在浏览器里输入网址即可,换成httpclient怎么写??
谢谢!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货