https怎么用java进行访问
发布网友
发布时间:2022-04-20 04:58
我来回答
共2个回答
热心网友
时间:2023-06-23 09:29
没有证书认证的,如果想访问支付宝等,需要配置一个访问的公钥
public class HttpClient {
private String charset = "UTF-8";
private boolean safe = false;
private String url;
Map<String, String> headers = null;
public HttpClient(String url) {
this.url = url;
...
public String post(String httpStr) throws IOException {
if (this.safe) {
return this.sendhttpsReq("POST", "", headers);
.....
while ((byteread = in.read(buf)) != -1) {
result.append(buf, 0, byteread);
}
....
conn.setRequestMethod(method);
conn.setDoOutput(true);
}
});
conn.setRequestProperty("Content-Type", "text/html");
.....
}
StringBuilder result = new StringBuilder(100);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return "";
}
private static c
热心网友
时间:2023-06-23 09:29
用apache的httpclient。