我正在尝试获取 HttpReponse 的响应代码。我更改了获取响应的方法,但它不起作用。
在我使用这个 try & catch 之前:(url 是函数的参数)
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost method = new HttpPost(url);
if (params != null) {
method.setEntity(new UrlEncodedFormEntity(params));
}
HttpResponse response = httpclient .execute(method);
InputStream inputStream = response.getEntity().getContent();
String result = convertInputStreamToString(inputStream);
return result;
}
catch (ClientProtocolException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
return null;
}
但是这段代码给了我一个运行时错误HttpResponse response = httpclient .execute(method);
繁花如伊
烙印99
蝴蝶刀刀
随时随地看视频慕课网APP
相关分类