我有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