我有android应用程序,在android应用程序中我执行了mysql数据库表的select查询。如何从输入流获取字符串值?
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.mywebsite.com/select.php");
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs,HTTP.UTF_8));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
//if(compare is value here)
这里我想检查InputStream is
的价值。
,当我在浏览器中执行http://www.mywebsite.com/select.php
我得到这样{name : ashu}
或null
产值,但我怎么能比较这是我的代码,因为我无法检查is==null
:(
5种方法将InputStream转换为Java中的字符串http://javarevisited.blogspot.com/2012/08/convert-inputstream-to-string-java-example-tutorial.html – mmcrae 2014-10-08 14:56:47
并且可能您需要一个HttpGet – Blackbelt 2014-10-08 14:57:07