我已经使用了下面的代码HttpPost
,它执行成功。但看不到回复。我明白了InputStream
。我想知道里面的内容是什么。
我想显示为字符串格式。如何做到这一点。
HttpPost httppost = new HttpPost(requestURL);
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(params.length);
for (int postValueCount = 0; postValueCount < params.length; postValueCount++)
nameValuePairs.add(new BasicNameValuePair(params[postValueCount][0],params[postValueCount][1]));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
Log.d("HttpPostRequest","URL : " + httppost.getRequestLine().getUri());
Log.d("HttpPostRequest","Method : " + httppost.getRequestLine().getMethod());
Log.d("HttpPostRequest","Parameters : " + nameValuePairs);
response = httpclient.execute(httppost);
status = response.getStatusLine();
if (status.getReasonPhrase().equals("OK")) {
httpEntity=response.getEntity();
InputStream in = httpEntity.getContent();
return in;
} else {
Log.d("Http Status", status.getReasonPhrase());
}
}