2015-12-28 43 views
-2
HttpResponse response = httpclient.execute(httppost); 
BufferedReader reader = new BufferedReader(new InputStreamReader(is 
+0

您的代碼不完整。你有任何錯誤?你有什麼試圖理解這個問題? – Duston

+0

這是部分程序,但在HttpResponse響應= httpclient.execute(httppost)後到達程序;將停止 –

回答

0

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()。permitAll()。build(); StrictMode.setThreadPolicy(policy);

try 
    { 

     HttpClient httpclient = new DefaultHttpClient(); 
     HttpPost httppost = new HttpPost("http://127.0.0.1:8080/list.php"); 
     HttpResponse response = httpclient.execute(httppost); 
     HttpEntity entity = response.getEntity(); 
     is = entity.getContent(); 

    }catch(Exception e) 
    { 
     System.out.println("Exception 1"); 
    } 

    try { 

     BufferedReader reader = new BufferedReader(new InputStreamReader(is , "iso-8859-1"),20); 
     StringBuilder sb = new StringBuilder(); 
     while ((line = reader.readLine())!=null) 

      sb.append(line +"\n"); 
      result = sb.toString(); 
      is.close(); 
      System.out.println("----------------Here Is My Data-------------------"); 
      System.out.println(result); 


    } catch (Exception e) 
    { 
     System.out.println("Exception 2"); 
    } 
this is code but buffered reader stay empty 
+0

請修改您的問題,而不是發佈這個答案 –