Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. private static String receiveFromBackEnd(String url, String json) throws IOException, JSONException {
  2.         StringBuilder str = new StringBuilder();
  3.  
  4.         HttpClient httpclient = new DefaultHttpClient();
  5.         HttpPost httppost = new HttpPost(url);
  6.         httppost.addHeader(new BasicHeader("Content-Type",
  7.                 "application/json"));
  8.  
  9.         httppost.setEntity(new StringEntity(json));
  10.  
  11.         HttpResponse response = httpclient.execute(httppost);
  12.  
  13.         BufferedReader reader = new BufferedReader(new InputStreamReader(
  14.                 response.getEntity().getContent()));
  15.         String line;
  16.         while ((line = reader.readLine()) != null) {
  17.             str.append(line);
  18.         }
  19.  
  20.         return str.toString();
  21.     }