我使用以下代码从https网址
获取回复代码:
URL url = new URL(sURL);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod( "POST" );
urlConnection.setRequestProperty( "Content-Type", "application/x-www-form-urlencoded");
urlConnection.setRequestProperty( "charset", "utf-8");
urlConnection.setUseCaches( false );
urlConnection.setDoOutput(true);
//out = new BufferedOutputStream(urlConnection.getOutputStream());
try( DataOutputStream wr = new DataOutputStream( urlConnection.getOutputStream())) {
wr.writeBytes(getQuery(postParameters));
}
BufferedReader in = new BufferedReader(
new InputStreamReader(urlConnection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
// HttpResponse r = client.execute(post);
int status = urlConnection.getResponseCode();
Log.i(TAG, "Got a response back from the server: " + status);
if (status == 200) {
//HttpEntity e = r.getEntity();
jsondatastring = inputLine;//EntityUtils.toString(e);
jarray = new JSONArray(jsondatastring);
jsonObject = jarray.getJSONObject(0);
Log.i(TAG, "Got the JSON data . returning the json object");
}
有错误javax.net.ssl.SSLHandshakeException:SSL握手已中止:ssl = 0xb91ab9d8:系统调用期间的I / O错误,同级连接重置
如何成功连接到Https网址?
任何帮助或想法都将受到赞赏。
由于